Reputation: 1
I am trying to retrieve data that has been stored into php mysql. When I tried to execute code below, I get an error which is:
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();
?>
Upvotes: 0
Views: 52
Reputation: 121
plenty of reasons...1 1. user on mysql doesnt have rights to access from students 2. columns do not exist in DB
Upvotes: 1