I have this code, but strangely it always echos out “yes!”, even if there is no such value as ‘555’ in FLD2 or even if there’s no FLD2 at all.
$testresult = mysqli_query($database, "SELECT * FROM imei359327039828680 WHERE FLD2 = '555'");
if ( $testresult ) { echo('yes!'); } else { echo('no!'); }
Any idea, thanks!
As was mentioned by ctshryock, a variable set to the returned value of a well-formed SQL query will always be seen as true when reviewed as a boolean object.
To test whether any data was returned, you could use
mysql_num_rows()PHP Documentation which will return the number of rows returned. If your query would not match any rows, then this function should return 0 which would be seen as false by anif()condition.