I don't know why the first time I created a table. UTF-8 cannot contain multiple Chinese characters. I used gb2312 instead of creating the table. As a result, the server database encountered a coding problem and had a headache. In this idle time, the table creation experiment proves that UTF-8 can withstand multiple Chinese characters. In this way, you can avoid the problem of unclear character conversion in the future. The method is as follows:
Create a MySQL table:
Create Table t_utf8
(
Id int not null auto_increment,
Title varchar (20) not null,
Contnet varchar (300) defalut null,
Primary Key ('id ')
) Begin = MyISAM default charset = utf8;
Note: When querying the database, set the default Character Set of the database to gb2312. Otherwise, a bunch of question marks will be displayed when you open the database ??.
PHP program:
<? PHP
$ Link = mysql_connect (host, username, PWD)
Mysql_select_db (Database, $ link );
/*
Insert Chinese Characters
Mysql_query ("set names utf8"); // ensure that UTF-8 data is inserted into the database.
$ Re = mysql_query ("insert into t_utf8 (title, content) values ('Chinese characters ', 'Chinese character set Chinese Character Set character Set Chinese Character Set ') ");
*/
Mysql_query ("set names utf8"); // ensure that data is output with UTF-8
$ Re = mysql_query ("select * From t_utf8 ");
While ($ ROW = mysql_fetch_array ($ re ))
{
Echo "". $ row [1]. "<br/>". $ row [2];
}
?>