【问题标题】:cant fetch data from mysql无法从mysql获取数据
【发布时间】:2017-07-08 03:06:17
【问题描述】:

`

                $sql = "SELECT * FROM tbl_feedback where status='Pending'";
                $result = $conn->query($sql);

                if ($result->num_rows > 0) {
                        $i=1;

                // output data of each row
                while($row = $result->fetch_assoc()) {
                $loc=$row['location'];
                $inci=$row['incident'];
                $sol=$row['solution'];


                echo "<tr>
                    <td>
                    <a href=editrecipient.php?feed_id=" . $row['feed_id'] . "><button type=button class='btn btn-info btn-xs' data-toggle='tooltip' data-placement='left' title='Edit'><i class='fa fa-pencil'></i></button></a>
                    <a href=recprofile.php?feed_id=" . $row['feed_id'] . "><button type=button class='btn btn-danger btn-xs' data-toggle='tooltip' data-placement='right' title='Delete'><i class='fa fa-trash'></i></button></a>
                    </td>
                    <td>$i</td>
                    <td>$loc</td>
                    <td>$inci</td>
                    <td>$sol</td>
                    <td><button type='button' class='btn btn-default btn-xs'>Post Feedback</button></td>


              </tr>";
              $i++;
                }
                    } else {
                    echo "0 results";
                    }
                $conn->close();


              ?>

` 这是错误消息 警告:mysqli::query(): Couldn't fetch mysqli in C:\xampp2\htdocs\Sahana\residentfeedback.php on line 222

注意:试图在第 224 行的 C:\xampp2\htdocs\Sahana\residentfeedback.php 中获取非对象的属性 0 个结果 警告:mysqli::close(): Couldn't fetch mysqli in C:\xampp2\htdocs\Sahana\residentfeedback.php on line 252

【问题讨论】:

标签: php html mysql mysqli


【解决方案1】:

我相信在查询之后添加关闭语句有一些规则,但我似乎找不到它。

尝试添加 $result->close();在sql执行之后。

【讨论】:

    猜你喜欢
    • 2021-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 2021-04-16
    • 2018-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多