我不斷收到這個錯誤,但我不知道爲什麼....PDO錯誤未捕獲的異常SQLSTATE [HY000]
的錯誤是:
Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]:
General error' in test.php:25\nStack trace:\n#0 test.php(25):
PDOStatement->fetch()\n#1 {main}\n thrown in test.php on line 25
我的查詢是這樣的:
$stmt = $pdo->prepare("
SELECT *,t1.id AS theID FROM users
t1 LEFT JOIN users_settings t2
ON t1.id=t2.tid
INNER JOIN extra_settings t3
ON t2.bid=t3.id");
try {
$stmt->execute();
} catch (PDOException $e) {
echo $e -> getMessage();
}
while($row = $stmt->fetch()){ //error is here
//do stuff
}
該腳本,但錯誤顯示反正=/
什麼是錯誤的含義及如何解決呢?
可能重複的[爲什麼SQLSTATE \ [HY000 \]:常規錯誤(http://stackoverflow.com/questions/10199571/why-sqlstatehy000-general-error) – hjpotter92 2013-02-19 05:11:58
答案有沒有沒有解決我的問題,所以不是真的重複。 – Sir 2013-02-19 05:14:01
@Dave只是爲了仔細檢查,如果在SQL提示符下輸入,查詢會給出正確的結果,並且'execute()不會給出任何錯誤輸出給頁面? – 2013-02-19 05:17:11