Click to See Complete Forum and Search --> : help please


publicitystunt
02-02-2006, 09:42 PM
why do these:

// Check if the username exists

$usernameinuse = mysql_query("SELECT * FROM userdata WHERE userid = '$username'");

$isusernameinuse = mysql_num_rows($usernameinuse);

// Find out how many users there are so that you can determine the next user number

$usercount = mysql_query("SELECT * FROM userdata");

$noofusers = mysql_num_rows($usercount);

produce these (error messages returned to me in the browser)(respectively):

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/studygui/public_html/php/createnewuser.php on line 361

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/studygui/public_html/php/createnewuser.php on line 385

any help would be greatly appreciated, if there is not enough information here to solve the problem i have the entire script, but i think that this is the problem thanks again

NogDog
02-02-2006, 09:59 PM
Because your queries failed to execute for some reason. Try using this format in order to gather some debug info:

$query = "SELECT * FROM userdata WHERE userid = '$username'";
$usernameinuse = mysql_query($query) or die("SQL ERROR: $query - ".mysql_error());

LiLcRaZyFuZzY
02-03-2006, 01:00 AM
probably because the query failed, so the returned value was boolean (FALSE) instead of a resource handle, the mysql_num_rows() (http://www.php.net/mysql-num-rows) function only accepts resources as parameter.