I am trying to make sure that my function return false
only if count
for cc
is 0
. I keep getting false
back from my function even when count
is more than 0
.
My function:
function db_cc_exists($link, $cc) {
$sql = "SELECT count(*) as count FROM visitors WHERE cc = '$cc' LIMIT 1";
$result = mysqli_query($link, $sql);
$row = mysqli_fetch_array($result);
$ret = $row[0];
mysqli_free_result($result);
return (intval($ret) == 0 ? FALSE : TRUE);
}
$link
is the connection of my database.