Web Analytics Made Easy -
StatCounter My Sql Errors - CodingForum

Announcement

Collapse
No announcement yet.

My Sql Errors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • My Sql Errors

    Hi Guys

    Please help, I am trying to create a register.php file and i keep getting the following errors

    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/httpd/vhosts/y-drop.com/httpdocs/php/users/reg.php on line 147

    Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource in /home/httpd/vhosts/y-drop.com/httpdocs/php/users/reg.php on line 148

    Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/httpd/vhosts/y-drop.com/httpdocs/php/users/reg.php on line 160

    with this bit of code
    PHP Code:
    function usernameTaken($username){
       global 
    $conn;
       if(!
    get_magic_quotes_gpc()){
          
    $username addslashes($username);
       }
       
    $q "select userid from user_id where userid = '$username'";
       
    $result mysql_query($q,$conn);
       return (
    mysql_numrows($result) > 0);
    }

    function 
    addNewUser($title$f_name$surname$address1$address2$towncity$countystate$zippostcode$country$telnum$mobnum$faxnum$email$username$password){
       global 
    $conn;
       
    $q "INSERT INTO users (title, f_name, s_name, add1, add2, town_city, county_state, zip_post, country, telephone, mobile, fax, email_1, userid) VALUES('$title', '$f_name', '$surname', '$address1', '$address2', '$towncity', '$countystate', '$zippostcode', '$country', '$telnum', '$mobnum', '$faxnum', '$email', '$username')";
       
    $q "INSERT INTO user_id (userid, pin, email, secret_q, secret_a, f_name) VALUES('$username', '$password', '$email', '0', '0', '$f_name')";
       return 
    mysql_query($q,$conn);

    please help, im really getting frustrated with this and after looking at it for about 30 mins my eyes start to go nuts

    Thanks
    Pete

  • #2
    Quick fix, change

    return mysql_query($q,$conn);

    into

    return mysql_query($q);


    Since the link resource is optional for mysql_query. The server will then use the last openend connection, wich will probably be exactly the same asintended.

    Real fix: you need to look at you connectionstrings, wherre you should have something like

    $conn=mysql_conect("localhost', ...);

    And this $connn should not be altered afterwards. So i don't quite see any use for that
    global $conn;
    that you have in each function
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

    Comment

    Working...
    X