2010-04-22 67 views
4

這裏的查詢:爲什麼這個正確逃脫的SQL查詢失敗?

INSERT INTO jobemails (jobid, to, subject, message, headers, datesent) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06') 

的數據類型是正確的,它總是失敗的問題,因此它必須是我如何逃脫的價值觀,我想。

我敢肯定你們其中一個會馬上看到我的白癡錯誤。一點幫助?

回答

8

SQL將行'to'混淆爲函數。

嘗試:

INSERT INTO `jobemails` (`jobid`, `to`, `subject`, `message`, `headers`, `datesent`) VALUES ('340', '[email protected]', 'We\'ve received your request for a photo shoot called \'another\'.', 'message', 'headers', '2010-04-22 15:55:06') 
+1

我絕對最差有關。我需要在mysql中更改該列的名稱,並使用MYSQL RESERVED WORDS停止列名。天啊!謝謝,Nican。 – rhodesjason 2010-04-22 20:07:28

+0

我可以在8分鐘內明顯接受你的答案...... – rhodesjason 2010-04-22 20:11:31

+0

只有在避免垃圾郵件發送者的情況下才有意義。謝謝你花時間獎勵我。 – Nican 2010-04-22 20:14:36