dousou2897 2014-03-28 20:22
浏览 356
已采纳

致命错误:调用未定义的方法mysqli :: num_rows()[复制]

This question already has an answer here:

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.

</div>
  • 写回答

2条回答 默认 最新

  • dongzhuo0895 2014-03-28 20:24
    关注

    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;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 如何解决访问网址被屏蔽的情况
  • ¥15 本地运行的vue2项目,使用内网穿透,前端界面一直转圈圈
  • ¥20 powerbuilder datawindow控件导出Excel数据,可不可以不自动覆盖原数据,而是在后面新插入入数据。
  • ¥100 无轴承永磁同步电机控制
  • ¥15 eps里添加本地倾斜模型
  • ¥15 telegram 问题
  • ¥15 nrf52810-c三个a 程序
  • ¥50 求一个半透明没有锯齿的圆角窗体的实现例子
  • ¥15 STM32cubeMX里的FreeRTOS无法释放内存
  • ¥15 CATIA有些零件打开直接单机确定终止