PHP must execute SETNAMESUTF8 after connecting to the database to prevent incorrect settings of a mysql character set. Today, I suddenly wanted to test it. Then I tried to comment out SETNAMESUTF8 and put the {code...} of mysql ...} set all global to utf8, and then find the inserted text... PHP must be executed after connecting to the database
SET NAMES UTF8
To prevent incorrect mysql Character Set settings.
Today, I suddenly want to test it, and then trySET NAMES UTF8
Comment out and comment out the mysql end
character_set_connectioncharacter_set_resultscharacter_set_servercharacter_set_client
Allglobal
Setutf8
Then, we found that Chinese characters were inserted with garbled characters, and the whole person was not good.
The local code and database must beUTF8
Of
If you followclient->connection->server
There is no problem in troubleshooting. Why?
Reply content:
PHP must be executed after connecting to the databaseSET NAMES UTF8
To prevent incorrect mysql Character Set settings.
Today, I suddenly want to test it, and then trySET NAMES UTF8
Comment out and comment out the mysql end
character_set_connectioncharacter_set_resultscharacter_set_servercharacter_set_client
Allglobal
Setutf8
Then, we found that Chinese characters were inserted with garbled characters, and the whole person was not good.
The local code and database must beUTF8
Of
If you followclient->connection->server
There is no problem in troubleshooting. Why?
In connection settings, specify UTF-8 encoding