Write it down first, so that you don’t have to remember it and look for it everywhere later!
When PHP operates the database, the data in the database uses UTF8 encoding. When it is read out, all that is displayed is ???????question marks and garbled characters. Find it. It turned out that some data was encoded before reading:
Copy code The code is as follows:
create table tablename
(
id int not null auto_increment,
title varchar(20) not null,
contnet varchar(300) defalut null,
primary key ('id')
)begin= MyISAM DEFAULT CHARSET =UTF8;
Execute before inserting data:
Copy code The code is as follows:
mysql_query("SET NAMES utf8");
Then
mysql_query("insert into tablename....")
Execute before reading out the data:
Copy code The code is as follows:
mysql_query("SET NAMES utf8");
Then mysql_query("select * from tablename")
Note: The encoding read here is output after re-encoding the original encoded content. For example, the page where the output content is located is GBK encoded, then when reading out The page display is also garbled, so execute mysql_query("SET NAMES gbk") before querying, and the GBK-encoded text content can be displayed normally on the page.
http://www.bkjia.com/PHPjc/320994.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320994.htmlTechArticleWrite it down first so that you don’t have to remember it and look for it everywhere later! When PHP operates the database, the data in the database is used UTF8 encoding, when I read it out, all it showed was ??????? question mark garbled characters, I found some...