Multiple SQL Queries, One Result - Help?
Posted: Mon Jan 25, 2010 10:56 am
So I'm writing a shopping cart, and one of the functions is when someone visits an individual product view they're given a view of 'related products', All product records have a field called 'keywords' which contains a list of comma delimited keywords.
I construct the query with a loop, and I've been echoing it to inspect it before it gets passed to the mysql_query() function.
Here is the string, maybe one of you can tell me why this query doesn't work ... ?
$result = mysql_query($query);
$num=mysql_numrows($result);
The error i get is this: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource
I construct the query with a loop, and I've been echoing it to inspect it before it gets passed to the mysql_query() function.
Here is the string, maybe one of you can tell me why this query doesn't work ... ?
Code: Select all
SELECT * FROM books WHERE keywords LIKE %safety% OR keywords LIKE %marine% OR keywords LIKE %usmc% OR keywords LIKE %naval safety center% OR keywords LIKE %leader%$num=mysql_numrows($result);
The error i get is this: Warning: mysql_numrows(): supplied argument is not a valid MySQL result resource