Jump to content

Recommended Posts

For a while now, I've had a main site(gaming ladders) and a forum.  They're on two seperate databases so users would have to register twice to access them.  I made a script that loops through database records from the ladders and determines if the ladder user is registered on the forums.  If the user is registered on the forums, an account isn't created.  If the user is not registered on the forums, an account is created.  Now, before I ran the script, the total of the ladders users was 3,717.  The total forums users was 1,762.  After I ran the script, the total number of forums users is 5,047.  I also made a script that calculates the number of forums users that aren't registered on the ladders and the result was 0.  So it's obvious that 1,995 of the ladders users weren't registered on the forums since 3,717 - 1,762 = 1,995.  So that means 1,995 forum accounts would have to be created so everyone that didn't register on both the ladders and the forums could use both.  Shouldn't the total number of forums users be 3,717 if my logic is correct?

Link to comment
https://forums.phpfreaks.com/topic/75632-does-this-make-sense-to-you/
Share on other sites

Idk, maybe my logic is incorrect...

 

<?php

//Connect to My Gaming Ladder database
include('config/config.php');

if($_POST['convert']){
$query = mysql_query("SELECT * FROM users") or die("Error: ".mysql_error());

//How many MGL users are there?
$numusers = mysql_num_rows($query);

$addedusers = 0;

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=sha1($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... <br>";

//Connect to SMF database

	$query2 = mysql_query("SELECT * FROM smf_members WHERE emailAddress = '$email'", $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.<br>";
									$addedusers = $addedusers + 1;
						//Otherwise...			
						} else {

						  	   		echo "There was an error adding the MGL member <b>$alias</b> to the SMF forum database.<br>";

						}

			} else {

			  	   	echo "The MGL member <b>$alias</b> was not added because he/she is already a member of the SMF forum.<br>";

			}

	}

}
	echo "Database conversion complete.  A total of $addedusers My Gaming Ladder users have been successfuly added to SMF.";

} else {

  	   echo "<form action='".$_SERVER['PHP_SELF']." method='POST'><input type='submit' value='Convert' name='convert'></form>";
   
}

?>

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.