Home > Backend Development > PHP Tutorial > !mysql数据库中文输出乱码 有图有真相

!mysql数据库中文输出乱码 有图有真相

WBOY
Release: 2016-06-13 11:07:02
Original
948 people have browsed it

求助!mysql数据库中文输出乱码 有图有真相

本帖最后由 redenn 于 2012-11-19 21:38:00 编辑 求助啊。mysql数据库输出乱码啊
查询的字段是gbk的:

php的中的代码如下:


网页的编码如下:


网页上的后果如下:

求解啊  要怎么做呢? 哪错了啊
------解决方案--------------------
确认你的文件保存的时候是 ANSI还是UTF-8的
试试用  iconv('utf-8','gbk',$con['schoolname']);
统一编码就不会出现这样的情况

$link=mysql_content('','','','')or die('连接失败');
mysql_select_db($dbname,$link);
mysq_query('set names gbk'); //应该是在 连接完库 选择完表后写 而不是执行语句后写。
准确的来说  gb2312和gbk是有区别的,所以最好全部统一成gbk或者utf-8
Related labels:
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