I've just wrote a script for users signup, but everytime I go to check the database to see if the username exists, I get this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/site/public_html/members/register/confirm.php on line 81
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/site/public_html/members/register/confirm.php on line 92
The offending parts of the script are:
78 mysql_select_db($mysqldatabase, $mysqlconnection);
79 $query_username = "SELECT id FROM users WHERE username = '$username'";
80 $doquery_username = mysql_query($query_username);
81 $numrows_username = mysql_num_rows($doquery_username);
81 if($numrows_username > 0){
82 $regerror .= " - That username exists. Please choose another";
83 $username = "";
84 fatalerror();
85 exit;
}
The other bit is the same, but just checking for a registered e-mail.
Strange thing is - if I refresh the page - it works fine. I can't work it out
There are no other MySQL queries before this one either, other than the connection info:
$mysqlhostname = "localhost";
$mysqldatabase = "xxxxxxx";
$mysqlusername = "xxxxxxx";
$mysqlpassword = "xxxxxxx";
$mysqlconnection = mysql_pconnect($mysqlhostname, $mysqlusername, $mysqlpassword) or die(mysql_error());
Help?