Testing a SQL Query for True or False

Posted by KickingLettuce on Stack Overflow See other posts from Stack Overflow or by KickingLettuce
Published on 2012-12-09T04:31:44Z Indexed on 2012/12/09 5:04 UTC
Read the original article Hit count: 152

Filed under:
|
|
$sql = "SELECT # FROM users WHERE onduty = 1 AND loc_id = '{$site}';"; 
$result = mysql_query($sql);

I simply want to test if this is true or false. If it returns 0 rows, I want next line to be something like:

if (!$result) { //do this; }

However, in my test, I am getting false when I know it should be true. Is this sound logic here?

(note, yes I know I should be using mysqli_query, that is not what I am asking here)

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql