Search code examples
phpmysqlunicodebackslash

MySQL update/insert strips backslashes for unicode entries


I'm trying to insert/update a SQL field with JSON data that encodes unicode as \u, but it's stripping it out:

"Sauteéd -> ["Saute\u00e9d"]

However, it's being saved in the database like this:

["Sauteu00e9d"]

I've tried countless preg_replace and str_replace methods, but none of them work. Is there something I can do about this - it's driving me mad.

Thanks!


Solution

  • Use mysql_real_escape_string if you aren't.