views:

24

answers:

2

I convert my php array 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.

+1  A: 

Use mysql_real_escape_string() to escape string data before sending database so that mysql does not treat backslashes as an escape character.

eyazici
+1  A: 

Use mysql_real_escape_string to escape the string before inserting it into the database.

escapedJSON = mysql_real_escape_string(jsonEncodedString);
MarkD