TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource (http://www.talkphp.com/absolute-beginners/6334-warning-mysql_num_rows-supplied-argument-not-valid-mysql-result-resource.html)

twiggs462 07-25-2012 06:25 PM

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
 
A client of mine is having an issue with an admin area of their site that I never encountered before...

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

The code that is being referenced is:

Code:

// new sql to pull associated products for seleceted family

$restwoway = mysql_query("SELECT * FROM members order by name;");
$numrows=mysql_num_rows(restwoway);

if($numrows=0){
echo "Invalid entry";
}
else { ?>

Anyone see any errors here or... do you need me to provide additional details. I never seen this error before and not sure how to address it *!*. Thank you for any ideas you might have.

tony 07-29-2012 03:49 PM

it seems in this line:
PHP Code:

$numrows=mysql_num_rows(restwoway); 

you forgot the dollar sign for restwoway. But I think that is just a misstype. You could see if the $reswoway is an actual resource of the results (doing a var_dump or your preference) and not something else. Seems to me that the results of the query is the problem.

Hanzo 08-04-2012 03:18 AM

You're also assigning $numrows a value of 0 in your conditional. Know that if you don't need the else statement, just omit it. :)

Try this:

PHP Code:

// new sql to pull associated products for seleceted family 

 
$restwoway mysql_query("SELECT * FROM members ORDER BY name"); 

$numrows=mysql_num_rows($restwoway);  

if(
$numrows===0){

 echo 
"Invalid entry"




tony 08-04-2012 11:59 PM

Quote:

Originally Posted by Hanzo (Post 33209)
You're also assigning $numrows a value of 0 in your conditional...[/php]

Good catch on that! Those tricky equal signs.


All times are GMT. The time now is 10:43 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0