PHP Chinese Character Library or garbled display Solution
Source: Internet
Author: User
In the future, you must remember to define the character type.
Mysql_query ("set names 'gbk '")
The solution is that simple.
Today, I made a database query and released it. Code. Copy codeThe Code is as follows: <? PHP
/*
Filename: Query. php
Do: Get and show the data
Author: www.5dkx.com
*/
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 ("failed to connect to the database! \ N ");
$ Exec = "select * from $ table ";
// Echo $ exec;
$ Result = mysql_query ($ exec, $ conn) or die ("database query failed \ n ");
Echo "<Table border = 2> ";
For ($ cout = 0; $ cout <mysql_numrows ($ result); $ cout ++)
{
$ City = mysql_result ($ result, $ cout, city );
$ Name = mysql_result ($ result, $ cout, name );
$ Phone = mysql_result ($ result, $ cout, phone );
Echo "<tr> ";
Echo "City: $ City ";
Echo "Name: $ name ";
Echo "Phone: $ phone ";
Echo "</tr> ";
}
Echo "</table> ";
?>
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service