Reputation: 1979
I have a database with utf_general_ci
encoding in MySQL, when I insert data in Navicat or PhpMyAdmin and do queries there, the special characters are returned fine.
But in a php variable they are showing like this:
My database and collations:
and in my html doc if it is a normal
it shows the characters OK, it only not work when is a php variable
please help me
Upvotes: 1
Views: 3248
Reputation: 1210
Hei,
Firstly be sure you have this meta in html tag
<meta charset="UTF-8">
You can check also with this line in php, above you mysql extraction
header('Content-type: text/html; charset=utf-8');
If you store your special character in database as html code like this '
which is '
when you extract try to use this php function
htmlspecialchars_decode($your_text_from_db);
Upvotes: 0
Reputation: 31654
It's important to note that utf8 in mysql is fairly limited, especially utf8_general_ci. You might want to switch to utf8_unicode_ci or utf8mb4
What's the difference between utf8_general_ci and utf8_unicode_ci
http://mathiasbynens.be/notes/mysql-utf8mb4
Upvotes: 1