Write it down first, so that you won't be able to remember it again!
When using PHP to operate the database, the data in the database is UTF-8 encoded. when reading the data, all the information displayed is ??????? Question mark garbled, Found some information that was originally performed before reading the encoding settings:
Create Table tablename
(
Id int not null auto_increment,
Title varchar (20) not null,
Contnet varchar (300) defalut null,
Primary Key ('id ')
) Begin = MyISAMDefault charset = utf8;
Run the following command before inserting data:
Mysql_query ("Set names utf8");
Then mysql_query ("insert into tablename .....")
Run the following command before reading data:
Mysql_query ("Set names utf8");
Then mysql_query ("select * From tablename ")
Note: The encoding read here is output after the original encoding content is re-encoded. For example, if the output content is located on the GBK encoding page, garbled characters are displayed on the page, therefore, execute mysql_query ("Set namesGBK"), You can display the GBK-encoded text content on the page.