The database cannot display Chinese characters, but the frontend can display the output information. why? -Php Tutorial

Source: Internet
Author: User
The database cannot display Chinese characters, but the frontend can display the output information. why? After inserting Chinese characters, a bunch of garbled characters are displayed, but the data is output to the front-end, and the Chinese characters are displayed again. how can I solve the database garbled characters problem?


Reply to discussion (solution)

Previously, I encountered this problem in phpmyadmin.
It is because the utf8 format on phpmyadmin can be displayed in two different Chinese characters.
I don't know if you have this problem.

Where did you see the garbled code?

Modify the table encoding:
Alter table 'table name' default character set utf8 COLLATE utf8_bin
Modify the field encoding:
Alter table 'table name' CHANGE 'field name' CHAR (100) character set utf8 COLLATE utf8_bin NOT NULL

Enter the preceding two SQL statements in the database.

Where did you see the garbled code?


Chinese characters in the database are garbled

Set names latin1;

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.