ShoeLace1291 Posted November 1, 2007 Share Posted November 1, 2007 I've had a website/forum for a couple years now, but we were never able to figure out how to integrate our two softwares(My Gaming Ladder and SMF). So I figured I would make a script that goes through and selects users from My Gaming Ladder since there are more users registered there and insert them into the SMF database. My problem is that when I run the script, nothing happens, it just keeps loading and I don't know why. This is my code: <?php //Connect to My Gaming Ladder database include('config/config.php'); $query = mysql_query("SELECT * FROM users") or die("Error: ".mysql_error()); //How many MGL users are there? $numusers = mysql_num_rows($query); if($numusers == 0){ "There are no users registered on My Gaming Ladder."; } else { while($fetch=mysql_fetch_array($query)){ $id=$fetch["id"]; $alias=$fetch["alias"]; $pass=$fetch["pass"]; $email=$fetch["email"]; $icq=$fetch["icq"]; $aim=$fetch["$aim"]; $msn=$fetch["msn"]; $yahoo=$fetch["yahoo"]; $website=$fetch["website"]; $ipaddress=$fetch["ipaddress"]; echo "Converting MGL member <b>$alias</b> to SMF... "; //Connect to SMF database include('community/Settings.php'); mysql_connect($db_server, $db_user, $db_passwd) or die("Could not connect to SMF database server: ".mysql_error()); mysql_select_db($db_name) or die("Could not select SMF database: ".mysql_error()); $query2 = mysql_query("SELECT * FROM smf_members WHERE memberName = '$alias'") or die("Could not search users: ".mysql_error()); $exists = mysql_num_rows($query2); //If the selected user doesn't exist in the SMF forum database... if($exists != 1){ $query3 = "INSERT INTO smf_members (memberName,passwd,emailAddress,websiteUrl,ICQ,AIM,YIM,MSN,memberIP) values('$alias', '$pass', '$email', '$website', '$icq', '$aim', '$yahoo', '$msn', '$ipaddress')"; //If the query is successfull if(mysql_query($query3)){ echo "Added MGL member <b>$alias</b> to the SMF forum database."; //Otherwise... } else { echo "There was an error adding the MGL member <b>$alias</b> to the SMF forum database."; } } else { echo "The MGL member <b>$alias</b> was not added because he/she is already a member of the SMF forum."; } //Connect to MGL database for next loop include('config/config.php'); } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75621-database-convert-help/ Share on other sites More sharing options...
rajivgonsalves Posted November 1, 2007 Share Posted November 1, 2007 well you connecting to another database so your link should be new $newlink = mysql_connect($db_server, $db_user, $db_passwd,true) or die("Could not connect to SMF database server: ".mysql_error()); mysql_select_db($db_name,$newlink) or die("Could not select SMF database: ".mysql_error()); $query2 = mysql_query("SELECT * FROM smf_members WHERE memberName = '$alias'",$newlink) or die("Could not search users: ".mysql_error()); $exists = mysql_num_rows($query2); and mysql_query($query3,$newlink) Quote Link to comment https://forums.phpfreaks.com/topic/75621-database-convert-help/#findComment-382625 Share on other sites More sharing options...
ShoeLace1291 Posted November 1, 2007 Author Share Posted November 1, 2007 It still just keeps loading. Quote Link to comment https://forums.phpfreaks.com/topic/75621-database-convert-help/#findComment-382628 Share on other sites More sharing options...
rajivgonsalves Posted November 1, 2007 Share Posted November 1, 2007 it depends how many user u go try this following code, also one thing do you have ob_start() in your config file <?php //Connect to My Gaming Ladder database include('config/config.php'); $query = mysql_query("SELECT * FROM users") or die("Error: ".mysql_error()); //How many MGL users are there? $numusers = mysql_num_rows($query); include('community/Settings.php'); $hdlComDataBase = mysql_connect($db_server, $db_user, $db_passwd,true) or die("Could not connect to SMF database server: ".mysql_error()); mysql_select_db($db_name,$hdlComDataBase) or die("Could not select SMF database: ".mysql_error()); if($numusers == 0){ "There are no users registered on My Gaming Ladder."; } else { while($fetch=mysql_fetch_array($query, MYSQL_ASSOC)){ $id=$fetch["id"]; $alias=$fetch["alias"]; $pass=$fetch["pass"]; $email=$fetch["email"]; $icq=$fetch["icq"]; $aim=$fetch["$aim"]; $msn=$fetch["msn"]; $yahoo=$fetch["yahoo"]; $website=$fetch["website"]; $ipaddress=$fetch["ipaddress"]; echo "Converting MGL member <b>$alias</b> to SMF... "; //Connect to SMF database $query2 = mysql_query("SELECT * FROM smf_members WHERE memberName = '$alias'", $hdlComDataBase) or die("Could not search users: ".mysql_error()); $exists = mysql_num_rows($query2); //If the selected user doesn't exist in the SMF forum database... if($exists==0){ $query3 = "INSERT INTO smf_members (memberName,passwd,emailAddress,websiteUrl,ICQ,AIM,YIM,MSN,memberIP) values ('$alias', '$pass', '$email', '$website', '$icq', '$aim', '$yahoo', '$msn', '$ipaddress')"; //If the query is successfull if(mysql_query($query3,$hdlComDataBase)){ echo "Added MGL member <b>$alias</b> to the SMF forum database."; //Otherwise... } else { echo "There was an error adding the MGL member <b>$alias</b> to the SMF forum database."; } } else { echo "The MGL member <b>$alias</b> was not added because he/she is already a member of the SMF forum."; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/75621-database-convert-help/#findComment-382629 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.