我正在尝试检索已存储到php mysql中的数据。当我尝试执行下面的代码时,出现错误:
注意:尝试在第27行的/storage/ssd5/459/2549459/public_html/x.php中获取非对象的属性 0结果
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();
?>
答案 0 :(得分:1)
有很多理由...... 1 1. mysql上的用户无权访问学生 2. DB
中不存在列