Solution to the problem of Chinese characters being stored or displayed as garbled characters in php_PHP Tutorial

WBOY
Release: 2016-07-21 15:39:20
Original
754 people have browsed it

In the future writing process, everyone 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 the code.

Copy code The code is as follows:

/*
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 character library n");
mysql_select_db($db)or die("Failed to connect to database!n");
$exec = " select * from $table";
//echo $exec;
$result = mysql_query($exec,$conn)or die("Failed to query database n");
echo "";
for($cout=0;$cout{
$city = mysql_result($result,$cout,city);
$name = mysql_result($result,$cout,name);
$phone = mysql_result($result,$cout,phone);
echo "
";
echo "city: $city";
echo "name: $name";
echo "phone: $phone";
echo "";
}
echo "";
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321573.htmlTechArticleEveryone must remember to define the character type in the future writing process. mysql_query("set names 'gbk'") The solution is that simple. I did a database query today and released the code...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template