forumnz Posted January 3, 2008 Share Posted January 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/84344-solved-warning-mysql_num_rows-error/ Share on other sites More sharing options...
GingerRobot Posted January 3, 2008 Share Posted January 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/84344-solved-warning-mysql_num_rows-error/#findComment-429604 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.