Character set encoding issue
All, Im having the age old problem with character encoding...
I have a mySQL DB with a field set to utf8_unicode_ci
. My PHP page as the header entry <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
. When I use a simple form to POST data with Cyrillic characters to the DB, e.g. 'гыдлпоо', the characters display correctly in the textarea, and are added to the DB where they d开发者_高级运维isplay correctly.
When fetching the characters from the DB, my page only displays a series of question marks. I've used mb_detect_encoding($content, "UTF-8,ISO-8859-1", true);
and the content is UTF-8, however the characters do not display.
I've searched around (including on SO) and tried any number of solutions, to no avail- any help would be much appreciated.
Many thanks
Do this right after mysql_connect() and mysql_select_db():
mysql_query("SET NAMES 'utf8'");
Try using mysql_set_charset() function before fetching data from database.
did you try to use the form with
enctype="multipart/form-data"
? this might help.. it's not necessary for the text to be readable in your database.. when they are saved they should be utf8 encoded.. you need them to look fine when you output the string again
精彩评论