I am inserting some data from a sjson
file into mysql
database. Some of the data is formatted using unicode
.
When I echo
the data on the browser is showing fine however, it is inserted in the database not formatted properly.
In the database I am using as Collation utf8_unicode_ci
.
JSON data:
anch\u2019io
, sar\u00e0
Showing in the Browser:
anch'io
, sarà
Showing in the mysql database:
anch’io
, sarÃ
How can I inserted in the database the text properly formatted?
PHP
$getUrl = "https://example.com/79809000.json";
$json_level = file_get_contents($getUrl);
$data_level = json_decode($json_level);
$text = $data_level->{"text"};
mysqli_query($conn, "INSERT INTO `70_level`(`text`) VALUES ('$text')");
I have tried to use addslashes
, htmlentities
but it does not work.