Today, the data is submitted to PHP through the form and then inserted into the database. Web page and PHP encoding format are utf-8, when inserted into the database is also set $this->query ("Set names UTF8;");
However, there is a case of reading data garbled and question marks in MySQL. Later, it is no solution, the MySQL set to GBK encoding, incredibly can be displayed correctly, is simply to subvert the three views. So far I don't know why.
But in this process also learned some knowledge about coding:
Set the MySQL encoding in MySQL by modifying the configuration file My.ini, which is under the installation path of MySQL.
[MySQL//client
Default-character-set=utf8
[MYSQLD]//server side
Character-set-server=utf8
operate under the MySQL client:
Show VARIABLES like ' character% '; view Character set
SHOW VARIABLES like ' collation_% ';
The way to solve garbled characters is to set the following MySQL three system parameters to the same character set as the server character set character-set-server before executing the SQL statement.
Character_set_client: The character set of the client.
Character_set_results: Result character Set.
Character_set_connection: The connection character set.
Set the three system parameters by sending a statement to MySQL: Set names UTF8
This is done in PHP: mysql_query ("Set names UTF8");
About the MySQL database encoding