我收到此代码未定义的索引错误:
// 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'];
}
错误:
Notice: Undefined index: custName in C:\xampp\htdocs\alxbook\index.php on line 40
我正在从我的表中选择所有列。我对 $row['roomNb'] 和 $row['date'] 没有问题,但由于某种原因 $row['custName'] 给我带来了问题。custName 的拼写正确。
这可能是什么原因造成的?