(转)php5.3中的连接MSSQLSERVER(非PDO方式)

说了这么多乱七八糟的话,言归正传:


我的系统环境:

win2003 sp2

本机安装了mssql2000

PHP5.3.6

IIS6.0

FastCGI安装方式安装的PHP

?

在网上找了很多的方式都不可以,用什么php_mssql.dll 之类的,从php5.2.X 到 php5.3.X 都做了测试,

全不解决问题,而且可能报出各种错误,总的来说在页面上的显示是 undefine function 的定义!

还在官方网站上找到了解决方法:


下载一个另一个组件: php_dblib.dll 就可以解决问题!

将php_dblib.dll到ext文件夹下, 并在php.ini文件里加入 extension=php_dblib.dll

这里要注意一下这个dll文件不要搞错了,我刚开始是用的Thread Safe 的版本,测试不成功,

因为我的php是用的 not Thread Safe 版, 所以应该选择 not Thread Safe 版的dll下载就可以了.

重启IIS, 测试通过!

?

$server='127.0.0.1:1433'; 
$username='sa'; 
$password='000000';

mssql_connect($server,$username,$password);
?
mssql_select_db('数据库名');
?
$sql="select * from 表名";
$rows=mssql_query($sql);
?
while($rs=mssql_fetch_assoc($rows)){
echo $rs['name']."<br>";
}

$sql="insert 表名(name) values('中国130123456')";
$rows=mssql_query($sql);


?

参考页面:

http://docs.moodle.org/en/Installing_MSSQL_for_PHP#Using_the_SQL_Server_2005_Driver_for_PHP_from_Microsoft_on_Windows

?

Using FreeTDS on Windows

Important Note 1: Due to some previous bugs it's highly recommendable to use PHP >= 5.2.6 and FreeTDS 0.82 + post-release patches (more info).

If your web server is on Windows, use php_dblib.dll. Despite the name, it's FreeTDS compiled for Windows. (Go to this page for information on Using FreeTDS for Unix.)

Originally we were using the DLLs available at Frank Kromann's site, but they are outdated (using old versions of FreeTDS) and that has caused some problems in the past.

So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:

1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.

    
PHP 5.2.x (vc6) Yes 0.82 + 20090302 patches Download!
No 0.82 + 20090302 patches Download!
PHP 5.3.x (vc9) Yes 0.82 + 20090904 patches Download!
No 0.82 + 20090904 patches Download!
Thanks to Remote-Learner] (Moodle Partner) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from freetds.org by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!

(alternatively here you can find some instructions to build those freetds extensions under win32yourself)


2. FreeTDS requires the .NET Framework v1.1 to be installed. You can download it from the Microsoft website along with its service pack. Alternatively, if you do not wish to install this framework, you can download the required DLL from Frank's site, and save it into your /PHP root directory.

?

转自:http://hi.baidu.com/zwfec/blog/item/3c54a3ec57c4433063d09f1e.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值