This is really weird.
This query obviously works:
$query = mysql_query("SELECT * FROM restaurant_page WHERE title LIKE '%$search_title%'");
But, this doesn’t:
$category = 'restaurant_page';
$query = mysql_query("SELECT * FROM '$category' WHERE title LIKE '%$search_title%'");
With the second query, I get the resource boolean error.
$category is table the user wants to search from. When I print out the query with the variable, it’s the exact same as the first one. Why wouldn’t this work?
Don’t use single quotes around your table name, use backticks (
`) instead:NB. Please make sure that
$categoryand$search_titleare not plain user provided variables