search
Homephp教程php手册php查询mssql出现乱码的解决方法

php查询mssql出现乱码的解决方法

Jun 13, 2016 am 09:17 AM
mssqlphpGarbled charactersspecificAppearanalyzemethodInquireofsolve

php查询mssql出现乱码的解决方法

 具体分析如下:

在php连接mssql时查询出来的全部是乱码,这种问题我根据经验知道是编码问题,下面来给各位总结一下解决方法.

方法一,修改php.ini文件,当然根据你页面情况来设置也可以是utf-8编码了,代码如下:

 

代码如下:

;mssql.charset = "ISO-8859-1"

 

mssql.charset = "GBK"

 

方法二,直接程序中转换,代码如下:

 

代码如下:

iconv('GB2312','UTF-8',$data)

 

方法三,利用Ado连接在连接时设置编码,代码如下:

 

代码如下:

$conn = new COM("ADODB.Connection", NULL, CP_UTF8) or die("Cannot start ADO");

 

PHP例子,代码如下:

 

代码如下:



");
//printaline("PLEASE?");
//print("This will not be displayed due to the above error.");
?>
$conn = new COM("ADODB.Connection", NULL, CP_UTF8) or die("Cannot start ADO");
//access 数据库的打开方式
//$conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db");
//$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db");
$conn->Open("Driver={SQL Server};Server={192.168.22.40};Database=sugarcrm_db;UID=sa;PWD=123456;") ;
// 执行查询并输出数据
$rs = $conn->Execute('SELECT * FROM accounts') or die ("error query");
?>
Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use