Php-mysql garbled.

Source: Internet
Author: User
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 UTF8To prevent incorrect mysql Character Set settings.

Today, I suddenly want to test it, and then trySET NAMES UTF8Comment out and comment out the mysql end

character_set_connectioncharacter_set_resultscharacter_set_servercharacter_set_client

AllglobalSetutf8

Then, we found that Chinese characters were inserted with garbled characters, and the whole person was not good.

The local code and database must beUTF8Of

If you followclient->connection->serverThere is no problem in troubleshooting. Why?

Reply content:

PHP must be executed after connecting to the databaseSET NAMES UTF8To prevent incorrect mysql Character Set settings.

Today, I suddenly want to test it, and then trySET NAMES UTF8Comment out and comment out the mysql end

character_set_connectioncharacter_set_resultscharacter_set_servercharacter_set_client

AllglobalSetutf8

Then, we found that Chinese characters were inserted with garbled characters, and the whole person was not good.

The local code and database must beUTF8Of

If you followclient->connection->serverThere is no problem in troubleshooting. Why?

In connection settings, specify UTF-8 encoding


   

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.