cliftonbazaar Posted December 14, 2010 Share Posted December 14, 2010 I have the following code $results=mysqli_query($mysqli, $sql_statement); and I wish to find out what happens if no results are returned. I have tried if(!$results) echo "Hello"; but nothing ever gets printed out So how can I find out if $results is empty? James Quote Link to comment Share on other sites More sharing options...
trq Posted December 14, 2010 Share Posted December 14, 2010 The general syntax is: if ($result = mysql_query($sql)) { if (mysql_num_rows($result)) { // free to use $result } else { // no result found } } else { // query failed } Quote Link to comment Share on other sites More sharing options...
cliftonbazaar Posted December 14, 2010 Author Share Posted December 14, 2010 Thanks for that, works perfectly Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.