PHP MySQL Error

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
Hello, I'm programming my new site and I have a really frustrating problem. I want to insert datas in two different DBs. The problem is, only the first one recieves the datas and the other one is ignored. Plus, there is NO ERROR MESSAGE eiter that appears!

Here is my whole code :



mysql_connect("localhost", "xxxxxx", "XXXXXX");

mysql_select_db("XXxxXX");



$email = stripslashes($_POST['newmail']);

$login = stripslashes($_POST['newlog']);

$password = stripslashes($_POST['newpsw']);

$password = md5($password);

$avatar = htmlentities($_POST['avatar_url']);

$dieu = stripslashes($_POST['dieu']);

$sexe_rpg = stripslashes($_POST['sexe_rpg']);

$race = stripslashes($_POST['race']);

$classe = stripslashes($_POST['classe']);

$sexe_irl = stripslashes($_POST['sexe_irl']);

$life_where = stripslashes($_POST['life_where']);

$year = stripslashes($_POST['dateyear']);

$register_time = time();



if ($race == "Sylvain" or $race == "Centaure de Toradrin")

{

$group_id = 10;

$clan = "Toradrin";

}

elseif ($race == "Fée" or $race == "Centaure de Shandel")

{

$group_id = 11;

$clan = "Shandel";

}

else{}



$str = 3;

$con = 3;

$dex = 3;

$cha = 3;

$spi = 3;



if ($race == "Sylvain")

{



$str = $str + 2;

$con = $con + 2;

$dex = $dex + 0;

$cha = $cha - 2;

$spi = $spi + 0;



}

elseif ($race == "Centaure de Shandel")

{



$str = $str - 2;

$con = $con + 0;

$dex = $dex + 2;

$cha = $cha + 2;

$spi = $spi + 0;



}

elseif ($race == "Centaure de Toradrin")

{



$str = $str + 0;

$con = $con + 0;

$dex = $dex + 2;

$cha = $cha + 2;

$spi = $spi - 2;



}

elseif ($race == "Fée")

{



$str = $str - 2;

$con = $con + 0;

$dex = $dex + 0;

$cha = $cha + 2;

$spi = $spi + 2;



}

else{}





if ($classe == "Sauvage")

{



$str = $str + 2;

$con = $con + 0;

$dex = $dex + 0;

$cha = $cha + 0;

$spi = $spi + 0;



}

elseif ($classe == "Rôdeur")

{



$str = $str + 0;

$con = $con + 0;

$dex = $dex + 2;

$cha = $cha + 0;

$spi = $spi + 0;



}

elseif ($classe == "Sorcier")

{



$str = $str + 0;

$con = $con + 0;

$dex = $dex + 0;

$cha = $cha + 0;

$spi = $spi + 2;



}

else{}



$mana = 1;

$health = 1;

$verificationlog_query = mysql_query("SELECT COUNT(*) FROM phpbb_users WHERE username='$login'");

$verificationmail_query = mysql_query("SELECT COUNT(*) FROM phpbb_users WHERE user_email='$email'");





if(@mysql_result($verificationlog_query,0,0)>0)

{

?>

<b>Nom déjà utilisé. (name already in use)</b>

<br><br>

<?

}

elseif(@mysql_result($verificationmail_query,0,0)>0)

{

?>

<b>Adresse électronique déjà existante. (email already in use))</b>

<br><br>

<?

}

else{





mysql_query("INSERT INTO phpbb_users VALUES('', '1', '$login', '$password', '0', '0', '0', '$register_time', '0', '0', '-5.00', '2', 'french', 'd M Y h:i a', '0', '0', '0', '0', '0', 'NULL', '1', '0', '1', '1', '1', '1', '0', '1', '0', '1', '0', 'NULL', '$avatar', '2', '$email', '', '', '$life_where', '', 'NULL', '', '', '', '', '', '', '')");



$user_id = mysql_query("SELECT * FROM phpbb_users WHERE username='$login'");

$user_id_final = mysql_fetch_array($user_id);

$user_identification_number = $user_id_final['user_id'];



mysql_query("INSERT INTO phpbb_user_group VALUES('$group_id', '$user_identification_number', '0')");





mysql_query("INSERT INTO phpbb_groups VALUES('', '1', '', 'Personal User', '0', '1')");

$last_id = mysql_insert_id();



mysql_query("INSERT INTO phpbb_user_group VALUES('$last_id', '$user_identification_number', '0')");


mysql_close() or die (mysql_error ());




mysql_connect("localhost", "xxxxxxx", "XXXXXXX") or die (mysql_error ());

mysql_select_db("xxXXxx2") or die (mysql_error ());

error_reporting(E_ALL);
ini_set('display_errors', 1);

mysql_query("INSERT INTO members VALUES('', '$login', '$password', '$email', '$year', '$life_where', '$sexe_irl', '$sexe_rpg', '$race', '$classe', '1', '$str', '$dex', '$con', '$spi', '$cha', '$dieu', 'Aucune', 'Aucune', 'Aucun', '0', '0', '0', '$clan', '$mana', '$health', '$clan', 'Membre', '10', '0', 'Aucune', 'Aucune', 'Aucun', '$register_time', '$register_time', '0', '0', '0', '0', '', '', '0')") or die("Couldn't insert data into table. mysqlERR:". mysql_error() );



mysql_close() or die (mysql_error ());





As you can see I wanted so much to see where was the error that I added mysql_error functions everywhere... still nothing appears
 

Corey

I Break Things
Staff member
Messages
34,553
Reaction score
204
Points
63
Try this with your queries;

$connA = mysql_connect("localhost", "xxxx", "xxxxx");
mysql_select_db("database1", $connA);

$connB = mysql_connect("localhost", "yyyyy", "yyyyy");
mysql_select_db("database2", $connB);

Now for your mysql statements use the $connA or $connB depending which database you are using.

eX:
mysql_query("INSERT INTO `tableA` ('var') VALUES ('$var')", $connA);
mysql_query("INSERT INTO `tableB` ('var') VALUES ('$varB')", $connB);

See if that works for you, try putting both mysql connects at the top of the file.

-Corey
 

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
Well, first I must say thanks to you for trying to help ;)

But I tried both things (with $connA, $connB everywhere after all the good queries) and also to put the $connB connection/queries BEFORE $connA.... still the same, $connB is ignored and $connA works fine.

This is getting me mad.
 
Last edited:

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
Oh my god, I'm so stupid.

It was ignored because the Table "members" has like 45 entries and my query was missing 2 of them. Now I tested and it works all fine.


BTW. Your help is not useless. I think I will always use $variables with mysql_connect ... it helps a lot.


THKS
 
Top