PHP reads MySQL Chinese data garbled [reprint]

Source: Internet
Author: User

Development Environment: apache2.0.54 + php5.1.6 + mysql5.0.26
Encoding: in order to make PHP and MySQL better support Chinese, will adopt UTF-8 encoding, the related configuration is as follows.
1. MySQL configuration, after installing MySQL, the character encoding is changed to UTF-8, that is, the second item is selected. Encode each table in a specific database into a UTF-8
2. There is no need to change in Apache because UTF-8 encoding is included
3. Line in the PHP. ini file
637: remove the semicolon before extension = php_mbstring.dll, and modify the relevant encoding configuration of mb_string. The modified content is as follows:
Line
1164: mbstring. Language = UTF-8
Line
1169: mbstring. internal_encoding =
UTF-8
Line 1172:
Mbstring. http_input = auto
Line
1176: mbstring. http_output =
UTF-8
Line
1183: mbstring. encoding_translation =
On
Line
1187: mbstring. detect_order = auto
Line
1191: mbstring. substitute_character =
UTF-8;
Line
1201: mbstring. func_overload =
1
(All row numbers correspond to PhP. ini-recommand of php5.1.6)
4. In the statement
$ Mysql_link = mysql_connect ($ mysql_host,
$ Mysql_user, $ mysql_pass );
Add

Mysql_query ("set names 'utf8 '");
Note: utf8 cannot be written as a UTF-8, otherwise it does not work

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.