Hi I am requesting help with my PHP. I checked the code through and I couldn't spot any errors in it.
I'm not that great with PHP, and I hope any of you could help.
It should return either false or true but, I get this error
Fatal error: Call to undefined method mysqli::num_rows()
Here is my code:
$mysqli is my mysqli database connector.
$email = $_SESSION["email"];
function isbanned($email){
global $mysqli;
if($mysqli->num_rows("SELECT * FROM `user_bans` WHERE `banned_id` = '".$email."' LIMIT 1") > 0){
return true;
}
return false;
}
isbanned($email);
That's all my code for the banned script.
Thanks in advance.
解决方案
That's not how that function is used. First you execute your query and then you check to see how many rows were returned from the returned result object:
$result = $mysqli->query("SELECT * FROM `user_bans` WHERE `banned_id` = '".$email."' LIMIT 1");
if($result->num_rows > 0){
return true;
}