Warning: mysql_num_rows():

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Warning: mysql_num_rows():

Post 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
    }
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Your Query is wrong. First execute and see it works or not
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Post 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.
me!
Forum Contributor
Posts: 133
Joined: Sat Nov 04, 2006 8:45 pm

Post by me! »

going for more coffee.... forgot the AND's....
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Just a suggestion, but error trapping might be useful in a situation like this... a la mysql_error()...
Post Reply