PHP 未获取表行数据,警告:mysqli_fetch_row() 期望参数 1 为

谁能帮我吗?我想显示完整的 mysql 数据库表结果,但出现错误:


我们有联系。


警告:mysqli_fetch_row() 期望参数 1 为 mysqli_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>

<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>  ```


智慧大石
浏览 110回答 1
1回答

慕丝7291255

您直接在 mysqli_fetch_row() 函数中传递查询,您应该传递 mysql 查询mysqli_query($connection,$query); 到 $querynew = mysqli_query($connection,$query); 并在 while($result = mysqli_fetch_row($querynew)){像下面这样$connection = mysqli_connect('127.0.0.1:3307','root','','loginapp');&nbsp; &nbsp; &nbsp; &nbsp; if($connection){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; echo "We are connected.";&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp; $query = "SELECT * FROM users";&nbsp; &nbsp; &nbsp; &nbsp; $querynew = mysqli_query($connection,$query);&nbsp; &nbsp; &nbsp; &nbsp; while($result = mysqli_fetch_row($querynew)){&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print_r($result);&nbsp; &nbsp; &nbsp; &nbsp; }
打开App,查看更多内容
随时随地看视频慕课网APP