Home  >  Article  >  php教程  >  php如何与mssql数据库连接与配置

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

WBOY
WBOYOriginal
2016-06-02 09:14:22957browse

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/>");
}


本文地址:

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

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