Forum Moderators: coopster

Message Too Old, No Replies

Php session and mysql

         

petenyce104

5:42 pm on Apr 23, 2003 (gmt 0)



I get this error

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

jatar_k

6:22 pm on Apr 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld petenyce104,

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>");

Fischerlaender

7:12 pm on Apr 23, 2003 (gmt 0)

10+ Year Member



Could you please post the query you are using; perhaps the problem lies in there.

DrDoc

7:20 pm on Apr 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$db_conn can probably be left out from the query:

$result = mysql_query($query);

grahamstewart

11:04 pm on Apr 23, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sounds like there is an error in your sql statement.
When this happens the mysql_query call will return false, but there won't be a corresponding php error.

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.