(转)php5.3中的连接MSSQLSERVER(非PDO方式)
2016-04-12 13:39
1131 查看
说了这么多乱七八糟的话,言归正传:
我的系统环境:
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.
(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
我的系统环境:
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! |
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
相关文章推荐
- phpcms v9 怎么给前台修改模板
- php构造方法之析构方法在继承中的表现
- IIS7.5 配置 PHP 5.3.5
- PHP常量详解:define和const的区别
- php 利用scws实现mysql全文搜索功能
- 可视化——matploblib 解决中文显示的问题
- PHP unicode 与 utf-8 转码,还是很有意思的
- 一份简短的关于 PHP 容易混淆知识点的实用指南
- 单例模式的数据库连接和PHP实现页面静态化的第一种方法
- Thinkphp控制volist的循环次数,限制只显示部分数据
- php通过Mysqli和PDO连接mysql数据详解
- PHP递归生成树形数组
- PHP中Restful api 错误提示返回值实现思路
- OutputFormat输出过程的学习
- php代码与表格元素的结合
- PHP给文字内容中的关键字进行套红处理
- PHP编码规范
- mac上调整phpstorm和webstorm的使用内存(默认是128m-750m) 避免卡顿
- PHP版本升级5.4手记
- thinkphp: Undefined class constant 'MYSQL_ATTR_INIT_COMMAND'