Home > php教程 > php手册 > linux下用php连接sqlserver解决办法

linux下用php连接sqlserver解决办法

WBOY
Release: 2016-06-21 09:15:59
Original
2190 people have browsed it

server|sqlserver|解决

步骤:
第一步:编译并安装freetds:
cd /tmp/
tar xzf freetds-*.tgz
cd freetds-*/
./configure --prefix=/usr/local/freetds
gmake
gmake install


第二步:编译并安装php4
./configure --with-mysql --with-sybase=/usr/local/freetds ....(后面的参数根据各自的需要不一而同)
#例子(我的编译参数): ./configure --prefix=/usr/local/php --with-mysql --with-apxs2=/usr/local/apache/bin/apxs --with-zlib --with-jpeg-dir=/usr --with-png --with-freetype --with-ttf --enable-gd-native-ttf --with-gd --enable-sockets --enable-dio --with-sybase=/usr/local/freetds --with-dom
make
make install


第三步:配置freetds
vim /usr/local/freetds/etc/freetds.conf
具体配置见该文件中的说明
例:
[MyServer2k]
host = 192.168.0.1
port = 1433
tds version = 8.0
并且可以把不用的JDBC区间注释掉


第四步:配置php.ini文件
修改相关的mssql区间配置,默认可以不用修改


第五步:测试
mssql_connect("192.168.0.1:1433","sa","");
mssql_select_db('testdb');
$sql = "SELECT * FROM test_table where condition = '条件';";
$result = mssql_query($sql);
$row = mssql_fetch_array($result);
print_r($row);
?>
不出意外的话,你将看到你期望的结果.

以上步骤在: Redhat 9.0, Apache 2.0.52, PHP 4.3.11 环境下通过.



Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template