PHP:更新记录错误,SQL语法错误

因此,我使用POST传输了一些数据,而我尝试使用我使用post发送的特定ID号更新该行。但是,我遇到了一个错误

Error updating record: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near $id'' at line 1

<?php
$conn = new mysqli("localhost", "root", "", "alumni");
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
$name = $_POST['name'];
$aproved =$_POST['aproved'];
$id =$_POST['id'];
$sql = "UPDATE students SET name='$name', aproved ='$aproved' WHERE id= '$id'";
if ($conn->query($sql) === TRUE) {
  echo "Record updated successfully";
} else {
  echo "Error updating record: " . $conn->error;
}
$conn->close();
?>

我的SQL语法有什么问题?

评论