Php-do not display or display garbled characters when writing Chinese data to mysql

Source: Internet
Author: User
When I write php today and insert data into mysql, Chinese characters or garbled characters cannot be displayed. how can this problem be solved? Character Set: mysql_query (& #39; SETNAMESutf8 & #39;); SQL statement: mysql_query (& quot; INSERTINTOuser (username) VALUES (& #39; pontong & #39;) & quot;); database table structure: usernamevarchar (20) utf8_general_ci and mysql configuration file my. I also changed it in ini, and garbled characters in the [mysql] [m mysqlphp Chinese Database

When I write php today and insert data into mysql, Chinese characters or garbled characters cannot be displayed. how can this problem be solved?
Character set already set:
Mysql_query ('set NAMES utf8 ');
SQL statement:
Mysql_query ("insert into user (username) VALUES ('pontong ')");

Database table structure:
Username varchar (20) utf8_general_ci

In addition, I also changed the mysql configuration file my. ini.
[Mysql] [mysqld] is followed
Default-character-set = utf8

How can this problem be solved?
Add:
Change the mysql encoding to gbk,
Mysql_query ('set NAMES gbk'); this line is also changed to gbk;
In phpMyadmin, Chinese characters are displayed, but Chinese characters cannot be displayed on the mysql client.

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.