0

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
  • Make sure you're always using mysql_real_escape_string or pdo/mysqli prepared statements, actually. This is really important to avoid SQL injection attacks as well as other problems. Commented Jul 1, 2010 at 19:59

2 Answers 2

2

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

escapedJSON = mysql_real_escape_string(jsonEncodedString);
Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.