+ Reply to Thread
Results 1 to 4 of 4

Thread: PHP MySQL Error

  1. #1
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Angry PHP MySQL Error

    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

  2. #2
    Corey's Avatar
    Corey is offline VPS Migration Professional Corey is a glorious beacon of lightCorey is a glorious beacon of light
    Join Date
    Dec 2004
    Location
    Northfield, NH
    Posts
    17,152

    Re: PHP MySQL Error

    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

  3. #3
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Re: PHP MySQL Error

    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 by Salvatos; 08-07-2006 at 08:13 AM.

  4. #4
    Salvatos's Avatar
    Salvatos is offline x10 Lieutenant Salvatos is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Québec, Canada
    Posts
    271

    Re: PHP MySQL Error

    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

+ Reply to Thread

Similar Threads

  1. [PHP] MySQL and PHP
    By Bryon in forum Tutorials
    Replies: 43
    Last Post: 03-24-2011, 07:27 AM
  2. tons of PHP Resources
    By Chris S in forum Scripts & 3rd Party Apps
    Replies: 10
    Last Post: 01-16-2009, 10:07 AM
  3. Unstand PHP?
    By o0slowpaul0o in forum Tutorials
    Replies: 8
    Last Post: 01-07-2008, 09:16 PM
  4. vBulletin mySQL error!
    By dphiance in forum Free Hosting
    Replies: 3
    Last Post: 06-11-2005, 02:28 AM
  5. Replies: 19
    Last Post: 04-05-2005, 05:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers