I have been using MySQL as backend to my PHP codings. Since I found a struck in fetching query results. If Im try to pass a query from function(PHP) like "SELECT count(col1) FROM mytable WHERE col1>55;" means, the possible results are: 1) Error - if query is wrong 2) 0 - if condition not satisfied 3) count result - if found 1 or more results Here My problem is, if the result may be on 1 or 2 means how can I check its ERROR or 0 from my code?
Say this is your query string: $query = "SELECT count(col1) FROM myTable WHERE col1 >55"; // This is the query that will be executed on the database $execute = mysql_query($query) or die (mysql_error()); // The mysql_query() function executes the query specified, but if it does not work (or die), then display the error MySQL gives. Simple as. // To find out of the number returned was 0, do this (I think) $row = mysql_fetch_array($execute); $num_returned = $row[0]; if($num_returned == 0) { echo "Statement returned 0; } PHP:
Almost like this one, but Im using these statements inside a function getCount("); - so dont want to echo mysql_error() at all. If Im getting values from that function it may return ERROR or VALUE . How can identify if 0 and ERROR or differ ? If u so interested solve it for me pls ?