我的PHP脚本有语法错误:
注意:尝试获取非对象的属性 C:\ xampp \ htdocs \ getallemlpoyees.php,第28行0结果
$sql = "SELECT id, firstname, lastname, FROM employees";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<br> ID: ".$row["id"]. "- firstname: ".$row["firstname"] ." lastname: ". $row["lastname"] . "<br>";
}
}
else {
echo "0 results";
}
答案 0 :(得分:1)
$sql = "SELECT id, firstname, lastname, FROM employees";
不要在lastname
之后加上逗号。