To create a website that contains Vietnamese files, the user said that MSYQL had garbled characters when saving the articles containing Vietnamese files. Let's test the Solution Below. Many characters have become ?. The utf8 character set is used for database connection. The Code is as follows: define (MYSQL_ENCODE, UTF8); mysql_query (SETNAMES. MYSQL_ENCODE, $ con
I made a website that contains Vietnamese files. The user said that MSYQL had garbled characters when saving the articles containing Vietnamese files. Let's test the Solution Below. Many characters have become? '. The utf8 character SET is used for database connection. The Code is as follows: define (MYSQL_ENCODE, UTF8); mysql_query ('set names'. MYSQL_ENCODE, $ con
To create a website containing Vietnamese files, the user says that MSYQL is garbled while saving the articles containing Vietnamese files. refer to the following solution:
I tested it myself. Many characters are changed '? '.
The utf8 character set is used for database connection:
The Code is as follows:
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:
The Code is as follows:
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