Home php教程 php手册 php连接mssql数据库与配置方法

php连接mssql数据库与配置方法

May 24, 2016 pm 06:30 PM

下面要来告诉各位朋友php连接mssql数据库并且与php mssql配置方法,这样如果你是初学者这文章可以让你从配置mssql 到让php连接mssql数据库的.

php连接mssql数据库,代码如下:

$localhost ='127.0.0.1';//mssql数据库ip 
$sa ='sa';//mssql登录用户名 
$pwd='123';//连接密码 
$db = 'cs';//数据库 
$conn=mssql_connect($localhost,$sa,$pwd) or die('mssql数据库连接失败'); 
mssql_select_db($db,$conn);//选择操作的数据库与mysql教程是相同的 
//query语句   
$query="select * from vc"; 
$adminresult=mssql_query($query) or die('sql'.$query); 
//输出结果 
while( $rs = mssql_fetch_array( $adminresult ) ) 
{
    echo $rs['0']; 
}
Copy after login

注意事项

1、打开php.in将extension=php_mssql.dll的注释符号去掉.

2、打开php.in将mssql.secure_connection = off改为on.

3、将php_mssql.dll拷贝到php.in中extension_dir 指定的目录或者系统system32目录下,php_mssql.dll在php压缩安装包中有.

以上步骤完成后需要重启apache.

注意:实际使用中发现如果通过php压缩文件手工安装php到iis下,必须重启机器而不仅仅是iis.

4、需要保证php或者系统系统system32下有ntwdblib.dll,查看属性确保其版本为8.00.194而不是7.0.


本文地址:

转载随意,但请附上文章地址:-)

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

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)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)