Mysql Database garbled Save Vietnamese text garbage solution _mysql

Source: Internet
Author: User


I test myself, many characters become '? '。

The database connection is already using the UTF8 character set:

Copy Code code as follows:

Define ("Mysql_encode", "UTF8");

mysql_query (' SET NAMES '. Mysql_encode, $conn) or Die (' character set error '. Mysql_error ());

For half an hour, I didn't get it.

Insert the data are still garbled, suddenly think, is not the field can not save these Vietnamese text.

I look at the database character set, the default is GBK, this to Chinese is no problem, a touch of Vietnamese text, it is garbled.

As a result, I modified the character set of the field that might be used in Vietnamese to UTF8, and proofread it to: Utf8_unicode_ci. (Here must specifically modify a field, modify the entire table's character set, does not work, the field or retain the original character set) problem solved.

My database is: Php_college_web

Table: City_article

Fields used in Vietnamese: Title,content

It then executes the following SQL:

Copy Code code as follows:

ALTER TABLE city_article Change title title VARCHAR (MB) CHARACTER SET UTF8 COLLATE utf8_unicode_ci

ALTER TABLE city_article Change content content text CHARACTER SET UTF8 COLLATE utf8_unicode_ci

Related Article

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.