【发布时间】:2020-02-14 01:19:52
【问题描述】:
这是我的尝试声明
$query = "DELETEh FROM supers WHERE id = :id";
try {
$stmt = $conn->prepare($query);
$stmt->bindValue(':id', $id);
$stmt->execute();
$_SESSION['notification'] = "Hero was deleted sucessfully";
}
这是剩下的代码
catch(PDOException $e) {
$_SESSION['notification'] = "There was an error deleting hero: " . $e->getMessage();
}
header("Location: notification.php");
exit;
当它运行时,它告诉我英雄被成功删除,尽管它没有成功,因为在 DELETE 之后有一个额外的“h”。谁能解释一下为什么这没有进入 catch 块?
【问题讨论】:
-
你确定你启用了
PDO::ERRMODE_EXCEPTION?