开发者

Json - Mysql Charset Problem

开发者 https://www.devze.com 2023-01-05 22:25 出处:网络
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 specia

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消