Jump to content

[SOLVED] Warning: mysql_num_rows(): ERROR


forumnz

Recommended Posts

I have modified my scrip to include the variable 'region', but now it won't work.

Heres the code snippet I modified:

 

$query = ("SELECT * FROM cmads WHERE AND (keyw LIKE '%$trimmed%' OR buzzname LIKE '%$trimmed%' OR descr LIKE '%$trimmed%' OR sub LIKE '%$trimmed%')
AND (region LIKE '$region') ORDER BY keyw"); 
$numresults=mysql_query($query);
$numrows=mysql_num_rows($numresults);

 

All I did was add the

AND (region LIKE '$region')

 

And my error:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /usr/local/www/vhosts/aaa/httpdocs/aaa/Results.php on line 84

 

Line 84 is:

 $numrows=mysql_num_rows($numresults);

 

Any idea?

 

Thanks,

Sam.

Link to comment
https://forums.phpfreaks.com/topic/84344-solved-warning-mysql_num_rows-error/
Share on other sites

There appears to be a stray 'AND' in there. Try:

 

$query = "SELECT * FROM cmads WHERE (keyw LIKE '%$trimmed%' OR buzzname LIKE '%$trimmed%' OR descr LIKE '%$trimmed%' OR sub LIKE '%$trimmed%')
AND (region LIKE '$region') ORDER BY keyw"; 
$numresults=mysql_query($query) or die(mysql_error().'<br />Query'.$query);
$numrows=mysql_num_rows($numresults);

 

I've also added an or die statement to the query - it'll show us the mysql error if there is one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.