Modify the default encoding. This code is really messy. When the database server is installed, no database code is selected. Query Database code PHPcodeshowcreatedatabaseguest; all are latin1. Search Google, there are the following questions, 1: Can the default-character-setgb2312 modify the global? (Modify the default character set of the database server) 2: the default encoding has been modified by latin1.
This code is really messy.
When the database server is installed, no database code is selected. Query Database encoding
PHP code
show create database guest;
All are latin1. Searched Google,
Have the following questions,
1: Can default-character-set = gb2312 be changed globally? (That is, modify the default character set of the database server)
2: latin1 by default. no encoding is specified during database creation. should latin be used at this time?
Php connects to the database. if I specify the encoding, how can this problem be solved?
PHP code
mysql_query(set names gb2312)
It seems to be written like this. do not blame new users.
------ Solution --------------------
Default-character-set in my. ini is the default character set of mysql.
If this parameter is modified, restart mysql.
If the modification is made, the requirements of other users must be taken into account!
If this parameter is not modified, the character set is not involved in all mysql applications. This will return to the original database.
In fact, mysql introduces the character set concept, but there is no subsequent action. For example, full-text search is still unavailable
------ Solution --------------------
When creating a database, set it to the encoding you need, such as utf8 gbk.
Php is executed when operating the database.
Mysql_query ("SETNAMES utf8"); // or SETNAMES gbk
Specify the encoding for the output page when obtaining the dataset.
Header ("Content-type: text/html; charset = utf-8"); // or gbk
For UTF-8 file encoding, remember to save the corresponding encoding.
And so on...
///////////////////////////////////
Export your data, re-set the database encoding, and then import the data. then, refer to the above method for operations.