[英]PHP Getting the following error: “Fatal error: Uncaught exception 'PDOException' ”
我正在嘗試使用以下功能檢索一行:
function get_registrar($key){
global $db;
$query = 'SELECT * FROM registration WHERE key = :key';
$statement = $db->prepare($query);
$statement->bindValue(':key', $key);
$statement->execute();
$result = $statement->fetch();
$statement->closeCursor();
return $result;
}
而且我不斷收到“致命錯誤:消息為'SQLSTATE [42000]的未捕獲異常'PDOException':”錯誤消息。 知道為什么會這樣嗎? 謝謝
鍵是保留的關鍵字
所以回勾它為
`key`
$query = 'SELECT * FROM registration WHERE `key` = :keyval';
這是保留關鍵字的列表
https://dev.mysql.com/doc/refman/5.5/zh-CN/reserved-words.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.