The database can only be managed by phpMyAdmin because of the server provider. The current database is queried using the show variables statement as follows:
Character_set_clientlatin1
Character_set_connectionutf8
Character_set_databaseutf8
Character_set_resultslatin1
Character_set_serverlatin1
Character_set_systemutf8
Collation_connectionutf8_unicode_ci
Collation_databaseutf8_unicode_ci
Collation_serverlatin1_swedish_ci
I have written a test file mytest.php code as follows (file encoded as UTF-8):
The display is garbled.
If you modify the code as follows and change the encoding of the file to ANSI. It will display normally.
What is this cause of garbled characters? What do you do if you want to work around this problem?
Reply content:
The database can only be managed by phpMyAdmin because of the server provider. The current database is queried using the show variables statement as follows:
Character_set_clientlatin1
Character_set_connectionutf8
Character_set_databaseutf8
Character_set_resultslatin1
Character_set_serverlatin1
Character_set_systemutf8
Collation_connectionutf8_unicode_ci
Collation_databaseutf8_unicode_ci
Collation_serverlatin1_swedish_ci
I have written a test file mytest.php code as follows (file encoded as UTF-8):
The display is garbled.
If you modify the code as follows and change the encoding of the file to ANSI. It will display normally.
What is this cause of garbled characters? What do you do if you want to work around this problem?
mysql_query ("Set names UTF8");
Before all query statements are placed in the linked database
And check if all the files are UTF8 encoded.
Finally, the meta-information of HTML code is increased UTF8 processing should be resolved
Unify the code. MySQL full-use utf8,php file as long as the UTF8 is OK, do not set another encoding.
Workaround:
3. Modify My.ini, add default-character-set = UTF8 in [client], [mysqld], [MySQL], mysqld, basedir in [DataDir].
[Client]
Default-character-set = UTF8
[Mysqld]
Default-character-set = UTF8
Default-collation=utf8_bin
init_connect= ' SET NAMES UTF8 '
Basedir=d:\mysql\
Datadir=d:\mysql\data\
[MySQL]
Default-character-set=utf8
Reference: Http://hi.baidu.com/hiran/blog/item/5 ...
Add: This service provider is also sick enough, the database is UTF8, the connection is also UTF8, the results are returned with latin1 ... That's why you're out there. If you cannot change the server configuration, you should try to turn the results back into UTF8 with iconv.
Add a try to the HTML tag .