Welcome to the Linux community forum and interact with 2 million technical staff to access the php Chinese character writing library and display garbled code: this problem occurs when the mysql database is not told in php that the data you want to insert is of the gbk type. The solution is actually very simple. after connecting to the database, you can add this sentence. in the future
Welcome to the Linux community forum, and interact with 2 million technical staff> solutions to the php Chinese character writing library and displaying garbled characters: this problem occurs when the mysql database is not told in php that the data you want to insert is of the gbk type. The solution is actually very simple. after connecting to the database, you can add this sentence. in the future
Welcome to the Linux community forum and interact with 2 million technicians>
Php Chinese character writing library and display garbled problem solution:
This problem occurs when the mysql database is not told in php that the data you want to insert is of the gbk type. The solution is actually very simple. After you connect to the database, you can add this sentence.
In the future, you must remember to define character types.
Mysql_query ("set names 'gbk '")
The following is the instance code:
/*
Filename: query. php
Do: get and show the data
Author: www.phpzixue.cn
*/
Include_once ("conn. php ");
Include_once ("include. php ");
Mysql_query ("set names 'gbk'") or die ("failed to set the Character Library \ n ");
Mysql_select_db ($ db) or die ("database connection failed! \ N ");
$ Exec = "select * from $ table ";
// Echo $ exec;
$ Result = mysql_query ($ exec, $ conn) or die ("database query failed \ n ");
Echo"
For ($ cout = 0; $ cout
$ Name = mysql_result ($ result, $ cout, name );
$ Phone = mysql_result ($ result, $ cout, phone );
Echo"
Echo "city: $ city ";
Echo "name: $ name ";
Echo "phone: $ phone ";
Echo"
}
Echo"
$ City = mysql_result ($ result, $ cout, city );
";
?>