mysql_num_rows提示未定义,致命错误:调用未定义的方法mysqli :: num_rows()

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;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值