Jump to content

[SOLVED] NumRows Help Please


phpretard

Recommended Posts

Can anyone see why this would return error: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 

$searchResult = mysql_query("SELECT * FROM members WHERE LicState LIKE '%$SEARCH%' OR LicState2 '%$SEARCH%' OR LicState3 LIKE '%$SEARCH%' OR LicState4 LIKE '%$SEARCH%' ");

if (!sql){die(mysql_error());}

$num_rows = mysql_num_rows($searchResult);

echo $num_rows." FOUND";

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/128936-solved-numrows-help-please/
Share on other sites

You're query is failing. The if() statement should read:

 

if(!$searchResult){
die(mysql_error());
}

 

Anything that results in an invalid MySQL Result Resource means that the query you can has something wrong with it. It's best to put queries in multiple lines as well, for readability and because it will tell you the error the line is on.

 

SELECT * FROM members 
WHERE LicState LIKE '%$SEARCH%' OR 
LicState2 '%$SEARCH%' OR 
LicState3 LIKE '%$SEARCH%' OR 
LicState4 LIKE '%$SEARCH%'

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.