Hello, I'm at wit's end with a php related problem and am hoping that someone here can help me. I'm sure the solution isn't very complicated, but I just can't think of it. Basically, I want to know if a query returns an empty result or not, without returning a php warning.
Code: Select all
SELECT item_id FROM content WHERE MATCH(item_title) AGAINST('$query_string' IN BOOLEAN MODE)
So basically I want to check the content table to see if $query_string exists in any of the item title's. If it does not, I want to run some code. Problem is, how do I do this query in php without getting a warning? Here's what I've been doing:
Code: Select all
$q = "SELECT item_id FROM content WHERE MATCH(item_title) AGAINST('$query_string' IN BOOLEAN MODE)";
$r = @mysqli_query ($dbc, $q);
//The following line causes the error
$query_result = mysqli_fetch_array($r, MYSQLI_ASSOC)
//this conditional checks if the result is or isnt null, thus identifying whether the query result was empty
if (sizeof($query_result) != 0) {
// result is not empty
} else {
// result is empty
}
(where $dbc is my database connection). When I run this, it works fine, but I get php warnings. Surely there's a better way of doing it, without getting warnings? Thanks in advance for any help.