2013-03-21 131 views
0

我有以下MySQL查詢:Mysql的語法錯誤(我無法找到是什麼錯誤!)

REPLACE INTO application (export_date,application_id,title,recommended_age,artist_name,seller_name,company_url,support_url) VALUES (1362564068339,564783832,Eyelashes,4+,Char Room,Char Room,http://,http://ios.charroom.net/,http://itunes.apple.com/app/) 

我收到以下錯誤:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Char Room,Char Room,http://,http://ios.charroom.net/,http://itunes.apple.com/app' at line 1 

我似乎無法看到的錯誤是。有人可以幫我嗎?

您必須知道上述內容是實際查詢的回聲。在查詢之前,此查詢中的所有參數都經過了mysql_real_escape_string。

回答

0

您必須在數據中插入數據的引號。

3

嗯,首先你shouldn't be usingmysql_real_escape_string

This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQL extension should be used.

其次,你仍然需要把周圍的字符串引號。 mysql_real_escape_string將在字符串內轉義引號,但不會將引號添加到開始和結尾。

+0

謝謝,正確的答案。 – 2013-03-21 22:08:23

+0

*最後*,只有大約十年(或兩年)慢的派對.. – 2013-03-21 22:09:51