I'm having some problems with my query that is always returning false, but it should return true if not exists. The problem is since the expression doesn't exists, it turns false false.
function isRegistered($mysqli, $username, $sitename, $status){
if($stmt = $mysqli->prepare("SELECT COUNT(*) FROM table1 WHERE username= ? AND sitename = ? AND status != ?")){
$stmt->bind_param("sss", $username, $sitename, $status);
$stmt->execute();
$stmt->store_result();
if($stmt->num_rows == 0){
return true;
}else{
return false;
}
}
}
I'm after that seeking if the function is true or false. If it's false, it trhows an error, if it's true, it follows for the next step. The problem is that always coming false (even if thats not true).
Basically the user only can register once in a specific area. So the first time it should be allowed, and the second time it doesnt. Could someone check what's going wrong with my query? Thanks