I'm getting an undefined index error with this code:
// Select all bookings
$sql = "SELECT * FROM booking";
$result = mysqli_query($con,$sql);
echo "<p>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
// echo $row['custName'] . " - " . $row['roomNb'] . " - " . $row['date'];
echo $row['custName'];
}
Error:
Notice: Undefined index: custName in C:\xampp\htdocs\alxbook\index.php on line 40
I'm selecting all columns from my table. I have no problem with $row['roomNb'] and $row['date'] but for some reason $row['custName'] is giving me problems. The spelling of custName is correct.
What could be causing this?