PHP Chinese garbled problem_PHP tutorial

WBOY
Release: 2016-07-13 17:33:19
Original
835 people have browsed it



(as the current mainstream development language)
$MySQL(the best combination with PHP)_server_name=localhost;
$ MySQL(The best combination with PHP)_username=root;
$MySQL(The best combination with PHP)_password=000000;
$MySQL(The best combination with PHP)_database=lib;
$conn=MySQL(The best combination with PHP)_connect($MySQL(With PHP The best combination)_server_name,$MySQL(The best combination with PHP)_username,$MySQL(The best combination with PHP)_password,$ MySQL(The best combination with PHP)_database);
$sql="select name,age from mytb";
print($conn);
$rs=MySQL (The best combination with PHP)_db_query("lib","select * from mytb",$conn);
print("
");
while($row = MySQL(The best combination with PHP)_fetch_object($rs)){
print ($row->name. ":".$row->age."
");
}
MySQL(The best combination with PHP)_close($conn);
?>
is displayed as follows:
Resource id #1
dd:54
ddd:8
??:15
???:25
??: 32
MySQL(The best combination with PHP)Encoding: utf8, GBK have been tried. MySQL(The best combination with PHP) font and command line.
Additional questions:
Garbled characters:
???:15
???:25
??:32
The values ​​in the database are Chinese characters. Question marks are displayed.

Solution:

in $rs=MySQL (the best combination with PHP) _db_query("lib"," select * from mytb",$conn);
is preceded by
MySQL (the best combination with PHP) _query("set names gb2312"); or MySQL( The best combination with PHP)_query("set names gbk");

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/508627.htmlTechArticlehtml head title/title /head body ?php (as the current mainstream development language) MySQL (matched with PHP The best combination) _server_name=localhost; MySQL (The best combination with PHP) _username=...
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!