2015-11-01 178 views
0

我不斷收到此錯誤:SQLSTATE [42000]:語法錯誤或訪問衝突:1064SQLSTATE [42000]:語法錯誤或訪問衝突:1064

這是查詢:

$query = $connection->prepare("INSERT into payments ([order],email,method,transaction) VALUES (:order,:email,:method,:transaction)"); 
$query->bindValue(":order",$orderid); 
$query->bindValue(":email",$payeremail); 
$query->bindValue(":method",$paypal); 
$query->bindValue(":transaction",$transaction_id); 
$query->execute(); 

的我在'訂單'周圍添加了[]的原因是因爲它是保留字?我得到這個錯誤有和沒有這些括號...

任何人都可以幫助我嗎?

我以前從未遇到過這個錯誤...

謝謝。

+0

爲什麼你會回滾我的更新?我刪除了不需要的空間。 – Script47

+0

對不起,我想我正在編輯,並且你在同一時間更新。我會嘗試你的解決方案 – user3882630

回答

1

對於保留字,您需要使用反勾號(``)不是方括號。

變化,

$query = $connection->prepare("INSERT into payments ([order],email,method,transaction) VALUES (:order,:email,:method,:transaction)"); 

要,

$query = $connection->prepare("INSERT into payments (`order`,email,method,transaction) VALUES (:order,:email,:method,:transaction)"); 
+0

謝謝,它的工作。 – user3882630

+0

@ user3882630很高興我能幫上忙。 – Script47

相關問題