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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.