php没有获取表行数据,警告:mysqli\u fetch\u row()期望参数1是mysqli\u result

k4emjkb1  于 2021-07-26  发布在  Java
关注(0)|答案(1)|浏览(435)

**结案。**此问题不可复制或由打字错误引起。它目前不接受答案。
**想改进这个问题吗?**更新问题,使其成为堆栈溢出的主题。

10个月前关门了。
改进这个问题
有人能帮我吗?我想显示完整的mysql数据库表结果,但出现错误:
我们是有联系的。
警告:mysqli\u fetch\u row()期望参数1是mysqli\u result,字符串在第28行的c:\xampp\htdocs\test\fetch.php中给出

$connection = mysqli_connect('127.0.0.1:3307','root','','loginapp');
    if($connection){

        echo "We are connected.";
    }

    $query = "SELECT * FROM users";

    mysqli_query($connection,$query);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Display</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
</head>
<body>

    <div class="container">

        <div class="col-md-6">

<?php while($result = mysqli_fetch_row($query)){

        print_r($result);
    } ?>

  </div>

    </div>

</body>
</html>  ```
4c8rllxm

4c8rllxm1#

您在mysqli\u fetch\u row()函数中直接传递query,您应该传递mysql query
mysqli\u query($connection,$query);to$querynew=mysqli\u query($connection,$query);并在while($result=mysqli\u fetch\u row($querynew))中使用$querynew{
如下所示

$connection = mysqli_connect('127.0.0.1:3307','root','','loginapp');
        if($connection){

            echo "We are connected.";
        }

        $query = "SELECT * FROM users";

        $querynew = mysqli_query($connection,$query);

        while($result = mysqli_fetch_row($querynew)){

            print_r($result);
        }

相关问题