Json - Mysql Charset Problem
I convert my php ar开发者_开发技巧ray to json using json_encode, Than I record this json data to my database .While json_encode encodes my data , It also converts strings to utf8 , this changes special characters to something like '/u011f' or '/u0131' . But when I write this converted data to mysql database , Backslashes are disappearing in field, so when I get this data back , html can not render characters correctly.
What should I do to keep backslashes.
Use mysql_real_escape_string to escape the string before inserting it into the database.
escapedJSON = mysql_real_escape_string(jsonEncodedString);
Use mysql_real_escape_string()
to escape string data before sending database so that mysql does not treat backslashes as an escape character.
精彩评论