PHP从表中选择不起作用

时间:2014-07-14 06:58:10

标签: php mysql sql mysqli

我从表中选择mysql有问题。你可以帮我纠正一下,或者至少告诉我,我做错了吗?感谢

$row = *mysqli_query($con, "SELECT  `user`, `pass` FROM `users` WHERE `user` = '$uname'");
if  ( $row && ['password'] == $pass ) {
    echo "Logged";
} else {
    echo "Incorect user/password";
}

1 个答案:

答案 0 :(得分:1)

对于成功的SELECT,SHOW,DESCRIBE或EXPLAIN查询mysqli_query将返回一个mysqli_result对象。您需要调用mysqli_fetch_array来从结果对象中获取行。

$res = mysqli_query($con, "SELECT  `user`, `pass` FROM `users` WHERE `user` = '$uname'");
$row = mysqli_fetch_array($res);