Forum Moderators: coopster
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/ehpadmin/http/docroot/authmain1.php on line 16
heres the code:
$result = mysql_query($query, $db_conn);
if ($result){
(mysql_num_rows($result) >0 )
$HTTP_SESSION_VARS['valid_user'] = $userid;
}
?>
So i dont know why i am getting this error, it works fine on local host on my machine but when doing server work i get this error. Any one know why
if ($result)
should tell you if the query was successful.
shouldn't there be an if or something before the parentheses here?
(mysql_num_rows($result) >0)
does the value of $query return any results? Have you echo'd your query to sure that it is constructed properly?
You could also try to add an or die to your mysql_query call to see if that is where the problem lies.
$result = mysql_query($query, $db_conn) or die (mysql_errno().": ".mysql_error()."<BR>");
To find out what the sql error is you have to check if the result is false and if it is use the mysql_error() function (as outlined by jatar_k above).
Also it would be a little more secure if you checked for exactly one row being returned, rather than more than zero. That way if someone manages to pass-thru some sneaky SQL there is less chance it will work.