Forum Moderators: coopster
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in......
I am working on a search for my DB. Nothing advance yet, just one input field for the search keyword. Here is my query:
$sqlQuery = "SELECT * FROM log WHERE wTemp like '%$thisKeyword%' OR wSpeed like '%$thisKeyword%'
OR wDirection like '%$thisKeyword%' OR sky like '%$thisKeyword%' OR precipitation like '%$thisKeyword%'
OR pressure like '%$thisKeyword%' OR moon like '%$thisKeyword%' OR spot like '%$thisKeyword%'
OR waterName like '%$thisKeyword%' OR waterTemp like '%$thisKeyword%' OR city '%$thisKeyword%'
OR state like '%$thisKeyword%' OR clarity like '%$thisKeyword%' OR bottom like '%$thisKeyword%'
OR bType like '%$thisKeyword%' OR bName like '%$thisKeyword%' OR rig like '%$thisKeyword%'
OR species like '%$thisKeyword%' OR length like '%$thisKeyword%' OR weight like '%$thisKeyword%'
OR cTime like '%$thisKeyword%' OR cDate like '%$thisKeyword%' OR cDepth like '%$thisKeyword%'"; If I do a single table field, it works good, but for some reason, this "OR" statement doesn't work.
Any ideas?
Thanks,
Mike
does it work with just 2 fields?
also, i'm not sure about variable interpolation in php, but could that be an issue?
mysql_query should return either a resource set or FALSE, so you could always try this:
$result = mysql_query($sqlQuery);
if (!$result) {
die('query error: ' . mysql_error());
}
The full error says this:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\wamp\www\FishingLog\search.php on line 38
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''%78%' OR state like '%78%' OR clarity like '%78%' OR bottom like '%78%' OR bTy' at line 1
line 38 in my code is where the "SELECT * FROM" starts.
I double checked the variable names and they all match up.
Thanks for the tip in trying 2. I just tested it, and it worked with 2 using the "OR" statement. So.........I guess I will keep adding additional fields in until it stops working.
Thanks,
Mike
I guess now I will go through and double check everything dealing with the city field.