-2

I'm trying to insert data into a mysql database, with the code below. Problem is, my json code containing the value "R\u00f8nde" is changed to "Ru00f8nde" after I insert it into the database.

What is the best way to avoid this?

INSERT INTO jos_payplans_user(user_id, params) VALUES ('24882', '{"modtager":"Anders And","adresse":"Paradisaeblevej 111","postnr":"1234","by":"R\u00f8nde","telefon":"12345678","user_notes":""}')
Dyvel
  • 847
  • 1
  • 8
  • 20
  • Properly prepare/bind/escape your values for SQL. [The Great Escapism (Or: What You Need To Know To Work With Text Within Text)](http://kunststube.net/escapism/) – deceze Oct 23 '18 at 13:33

1 Answers1

0

In json itself avoid the slashes and insert in db

echo json_encode($value, JSON_UNESCAPED_SLASHES);
Rp9
  • 1,955
  • 2
  • 23
  • 31
  • `JSON_UNESCAPED_SLASHES` foregoes escaping *slashes* (`/`). It has nothing to do with the *backslashes* in the question. It's also rather useless if you already have perfectly valid JSON which contains perfectly valid backslashes. – deceze Oct 23 '18 at 13:34