PHP MSSQL数据乱码的问题

WBOY
Release: 2016-06-23 14:22:24
Original
921 people have browsed it

PHP环境WINODWS PHP APACEH

PHP网页使用UTF-8编码

MSSQL 2008数据库,库和表排序规则Chinese_PRC_CI_AS,字段排序规则:Windows排序规则Chinese_PRC

现在读取数据库的数据,输出到网站出现乱码,请问如何解决这个问题?

网站已经声明:


回复讨论(解决方案)

Chinese_PRC_CI_AS
Chinese_PRC 大陆简体字UNICODE
CI 不区分大小写
AS 区分重音

UCS(unicode)系列中,大陆简体是 UCS-2
他和 UTF-16LE 相同,和 UTF-8 存在简单的位移运算

既然 UTF-8 和 UCS-2 是不同的,那么你当然要做编码转换

我是PHP新手,能不能举例说一下怎样转码,谢谢。

echo  iconv("GB2312","UTF-8//IGNORE",$str) ;
这里的$str是你从mssql数据表中读取的字段内容。
可以实验下

mysql_query("set names gb2312");用这个函数试一试

楼上的人家是MSSQL,楼主可以把utf-8改为GB2312即可,注意文件存储格式也要是ANSI或者是GB2312

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!