The solution of the MySQL database garbled method

Source: Internet
Author: User
Tags character set mysql database

To do a website containing Vietnamese, users said that in the preservation of articles containing Vietnamese, msyql garbled, look at the following solution

I test myself, many characters become '?   '。   The database connection is already using the UTF8 character set: The code is 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 in Vietnamese: Title,content executes the following SQL: The code is as follows: ALTER TABLE city_article Change Ti Tle title VARCHAR (MB) CHARACTER SET UTF8 COLLATE utf8_unicode_ci ALTER TABLE city_article Change content content text C Haracter 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.