Page 1 of 1

Warning: mysql_num_rows():

Posted: Sun Mar 04, 2007 11:47 pm
by me!
Why am I getting this, and how do I fix it?
:roll:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in server/address/index.php on line 310

Code: Select all

// check to see if this person is in the DB
$query = "SELECT * FROM table WHERE first_name='".pnVarPrepForStore($first_name)."', last_name='".pnVarPrepForStore($last_name)."', reg_year='".pnVarPrepForStore($reg_year)."'"; 
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
if($numrows == 0)
    {
     // do something
    }

Posted: Mon Mar 05, 2007 12:01 am
by dude81
Your Query is wrong. First execute and see it works or not

Posted: Mon Mar 05, 2007 12:09 am
by me!
:dubious: Ok what do you see that I am not.... I am looking at it and it looks "ok"?


It is in the code but I don't think it's working as it should but no errors except the warning.

Posted: Mon Mar 05, 2007 12:18 am
by me!
going for more coffee.... forgot the AND's....

Posted: Mon Mar 05, 2007 3:39 pm
by RobertGonzalez
Just a suggestion, but error trapping might be useful in a situation like this... a la mysql_error()...