php连接sql2000技巧详解

WBOY
Release: 2016-06-20 13:04:55
Original
1574 people have browsed it

php连接sql2000技巧详解

<?php

//用mssql_connect

$conn=mssql_connect('localhost','sa','111111') ;

if (!$conn)
  {
  die('没连接上: ' . mysql_error());
  }

mssql_select_db('test',$conn);

//query语句

$Query="select * from news";

$AdminResult=mssql_query($Query);

//输出结果

$Num=mssql_num_rows($AdminResult);

for($i=0;$i<$Num;$i++)

{

$Row=mssql_fetch_array($AdminResult);

echo($Row[1]);

echo("<br/>");

}

?>
Copy after login

先来复习一下怎么样用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:\windows\system32\文件夹下。

4、重启Apache,OK

当然还可以用pdo和ODBC来连接SQL Server。


Related labels:
php
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