Home php教程 php手册 php如何与mssql数据库连接与配置

php如何与mssql数据库连接与配置

Jun 02, 2016 am 09:14 AM

PHP自带的扩展php_mssql.dll连接SQL Server 2000,用mssql系列函数来操作,和操作MySQL的一样.

1、打开PHP配置文件php.ini,找到;extension=php_mssql.dll把前面的分号去掉.

2、找到mssql.secure_connection = Off修改成 mssql.secure_connection = On。

3、把PHP文件夹下的php_mssql.dll和ntwdblib.DLL这两个文件拷贝到C:windowssystem32文件夹下.

4、重启Apache,OK

php用mssql_connect,代码如下:

<?php
$conn = mssql_connect(&#39;localhost&#39;, &#39;pandao&#39;, &#39;1987&#39;) or die(&#39;111cn.net数据库连接不上&#39;);
mssql_select_db(&#39;test&#39;, $conn);
//query语句
$Query = "select * from news";
$AdminResult = mssql_query($Query);
//输出结果
$Num = mssql_num_rows($AdminResult);
for ($i = 0; $i < $Num; $i++) { //开源代码phprm.com
    $Row = mssql_fetch_array($AdminResult);
    echo ($Row[1]);
    echo ("<br/>");
}
Copy after login


本文地址:

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

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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

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)