Mysql database garbled-saving Vietnamese garbled-solution _ MySQL

Source: Internet
Author: User
Mysql database garbled saving Vietnamese garbled solution bitsCN.com


I tested it myself. many characters are changed '? '.

The utf8 character set is used for database connection:


Define ("MYSQL_ENCODE", "UTF8 ");

Mysql_query ('set names'. MYSQL_ENCODE, $ conn) or die ('character SET setting error'. mysql_error ());

It took more than half an hour.

The data in the insert statement is still garbled. I suddenly wondered if the field cannot store these Vietnamese files.

Let me take a look at the Database character set. the default character set is gbk. this is no problem with Chinese. when I encounter Vietnamese, it will be garbled.

Therefore, I changed the character set that may be used in Vietnamese fields to utf8, and the proofreading was changed to utf8_unicode_ci. (Here, you must modify a field to modify the character set of the entire table. The field still retains the original character set.) The problem is solved.

My database is php_college_web

Table: city_article

Fields used in Vietnamese: title and content

Execute the following SQL statement:


Alter table city_article CHANGE title VARCHAR (100) character set utf8 COLLATE utf8_unicode_ci

Alter table city_article CHANGE content text character set utf8 COLLATE utf8_unicode_ci

BitsCN.com

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.