我想使用pdo更新数据库中的记录。 连接应该不是问题,因为我已经将它用于GET和INSERT。
try {
// Create connection
$conn = new PDO("mysql:host=$servername; dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "
UPDATE tblanime
SET
title = '$title' ,
synonyms = '$synonyms' ,
episodes = '$episodes' ,
score = '$score' ,
type = '$type' ,
status = '$status' ,
start_date = '$start_date',
end_date = '$end_date' ,
synopsis = '$synopsis' ,
image = '$image'
WHERE 'id'='34096' ";
$conn->exec($sql);
}
catch(PDOException $e){
echo $sql . "<br>" . $e->getMessage();
}
$conn = null;
有人可以帮我理解出了什么问题吗? 亲切的问候,