Write it down before you can find it again!
When PHP operates the database, the data in the database uses UTF8 encoding, and when it is read out, it shows all the??????? The question mark garbled, looked for some data originally is before reads carries on the encoding setting:
Copy Code code as follows:
CREATE TABLE TableName
(
ID int NOT NULL auto_increment,
Title varchar NOT NULL,
Contnet varchar () defalut NULL,
Primary KEY (' ID ')
) Begin=myisam DEFAULT CHARSET =utf8;
To execute before inserting data:
Copy Code code as follows:
mysql_query ("SET NAMES UTF8");
And then
mysql_query ("INSERT INTO TableName ...")
Execute before reading data:
Copy Code code as follows:
mysql_query ("SET NAMES UTF8");
Then mysql_query ("SELECT * FROM TableName")
Note: The code read here is the original encoded content to be encoded after the output, such as the output of the page is GBK encoding, then read out in the page display is garbled, so before the query execution mysql_query ("SET NAMES GBK"), GBK encoded text can be displayed correctly on the page.