Re: [請益] 無法INSERT有西歐字母的資料

看板PHP作者 (Cindy Wang)時間14年前 (2011/07/03 22:18), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《asdd (我愛胖穎穎)》之銘言: : 當我在執行INSERT的時候 某些資料有西歐字母 確有錯誤訊息 : 1064: 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 'Association : francaise d'urologie et de la Societe francaise d'urologie','[Manage' at line : 1 : 請問該怎樣解決這樣的問題呢? : 另外當有多筆資料要INSERT,如果像上述情況無法INSERT的時候有沒有辦法讓他 : 自動忽略繼續執行其他資料的INSERT呢, 我查到的資料是寫 : 原本INSERT INTO 改成 INSERT ignore INTO就行了 : 不知道還有沒有其他方法呢? : 謝謝 應該是因為你用單引號來寫 SQL 的字串, 而你的內容裡面又出現了單引號的關係, 你可以利用 mysql_real_escape_string 來解決 (假設你是用 MySQL) http://php.net/manual/en/function.mysql-real-escape-string.php mysql_query("insert into .... values ('".mysql_real_escape_string($data)."', ..."); 這樣子~ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 210.242.246.249

07/03 23:18, , 1F
謝謝 已解決 果真是這樣子!!
07/03 23:18, 1F
※ 編輯: CindyLinz 來自: 210.242.246.249 (09/10 13:15)
文章代碼(AID): #1E47el85 (PHP)
文章代碼(AID): #1E47el85 (PHP)