doubingqi5829 2019-02-05 03:50
浏览 66

我的代码没有任何错误,但mysqli_num_rows给出零值

I made a login script in PHP, and the process needs to check whether data from login form is match with data in my table. I use mysqli_num_rows to do that. But it gives zero value. How can I fix this?

I have no idea but I've already tried a method with mysqli_fetch_array and the result is still same.

Edit : Table app_user has id_level, and id_level is a foreign key. Is there could be a problem in the database? But I'm not using id_level in the login process. Or it could be a xampp server error?

include "lib/conn.php";

$data = mysqli_query($conn, "SELECT * FROM app_user WHERE username='$user' AND password='$pass'") or die(mysqli_error($conn));
echo "<pre>".print_r($data, true)."</pre>";

if(mysqli_num_rows($data) == 0){
    $_SESSION['error'] = '<strong>ERROR!</strong> username atau password salah.';
    //header('Location:login.php');
    echo "x";
    die();
}

So, I want mysqli_num_rows to give me 1, but the existing output is 0.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿
    • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
    • ¥15 微信公众号自制会员卡没有收款渠道啊
    • ¥100 Jenkins自动化部署—悬赏100元
    • ¥15 关于#python#的问题:求帮写python代码
    • ¥20 MATLAB画图图形出现上下震荡的线条