Jump to content

Recommended Posts

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');

	}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/75621-database-convert-help/
Share on other sites

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)

Link to comment
https://forums.phpfreaks.com/topic/75621-database-convert-help/#findComment-382625
Share on other sites

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.";

			}

	}

}

?>

Link to comment
https://forums.phpfreaks.com/topic/75621-database-convert-help/#findComment-382629
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.