I have a database and a table in it which is looking like this
ID Picture Description.
In my PHP-Code I try to get the "Picture" which is just a text right now and the Description. But I always get
Undefined Index: Description
Undefined Index: Picture
Here my Code:
<?php include ("db.php");
$conn = new mysqli($servername, $username, $password, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT Picture, Description FROM family WHERE ID = 1 ";
$result = $conn->query($sql)
or die ("MySQL-Error: " . $conn->error);
if ($result->num_rows >0) {
while ($row = mysqli_fetch_row($result)){
echo "Pic: " . $row["Picture"]. " - Description: " . $row["Description"]. "
}
}
else {
echo "Not good";
}
$conn->close();
echo "Connected successfully"; ?>
What does the error mean
EDIT: I solved it changed mysqli_fetch_row
to mysqli_fetch_assoc