gpt4 book ai didi

php - 尝试从数据库检索数据时出错

转载 作者:行者123 更新时间:2023-11-29 10:11:38 25 4
gpt4 key购买 nike

我正在尝试检索已存储到 php mysql 中的数据。当我尝试执行下面的代码时,出现错误:

Notice: Trying to get property of non-object in /storage/ssd5/459/2549459/public_html/x.php on line 27 0 result

x.php

<?php 
$conn = mysqli_connect("localhost" , "id2549459_salamnti" , "0000000000" , "id2549459_tutorial");
if($conn -> connect_error){
die("my connection faild" . $conn -> connect_error);
}

$sql = "SELECT id, military_num , firstname, lastname,image from students";
$result = $conn-> query($sql);
if($result -> num_rows > 0){
while($row = $result-> fetch_assoc()){
echo "<tr> <td>" . $row["id"] . "</td> <td>" . $row["militry_num"] . "</td> <td>". $row["firstname"]. "</td><td>" . $row["lastname"] . "</td><td>" . $row["image"] . "</td> </tr>";
}
echo "</table>";
}
else{
echo "0 result";
}
$conn -> close();
?>

最佳答案

有很多理由...11. mysql用户无权学生访问2.数据库中不存在列

关于php - 尝试从数据库检索数据时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50867209/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com