PHP在*NIX平台下连MSSQL比较复杂,给你一篇文章:Procedure for M$SQL Support in PHP 4.0.5+/*NIX
==============================================
What We Need ?
==============
* PHP Source (latest)
* FreeTDS (http://www.freetds.org/) get latest stable version
* Patience!!!
* Dual Login Mode in SQL Server Enterprise Manager
(Windows ONLY login will not work!)
Installation Procedure !
========================
(1)
> tar -xzvf freetds-xxx.tgz
> cd freetds-xxx/
> ./configure --prefix=/usr/local/ftds --with-tdsver=4.2 --enable-dbmfix
> make && make install
(2)
> Edit your /etc/ld.so.conf (or equivalant) add /usr/local/ftds/lib to it
> run ldconfig (located in /sbin/ldconfig in linux)
(3) GET READY TO HACK!!!
> tar -xzvf php-xxx.tar.gz
> cd php-xxx/
> edit 'ext/sybase/config.m4', replace 'dbopen' with 'tdsdbopen'
(in version 4.0.6 of PHP this in on line 27 of config.m4)
> (I am not sure if this step is 100% necessary, but do it anyway!)
edit the 'configure' file and look for PHP_SYBASE_DBOPEN, you should see two
different versions of this. As follows:
#define PHP_SYBASE_DBOPEN tdsdbopen <-- leave this alone
#define PHP_SYBASE_DBOPEN dbopen <-- change this to #define PHP_SYBASE_DBOPEN tdsdbopen
(4)
> ./configure [put other php options here] --with-mssql=/usr/local/ftds --with-sybase=/usr/local/ftds
> make && make install
> cp php.ini-dist /usr/local/lib/php.ini (the location of this file may differ for your installation)
(5)
> Now, edit /usr/local/lib/php.ini file, look for 'sybase.interface_file' directive
> uncomment it and change the value to /usr/local/ftds/interfaces (location where you installed freeTDS)
(6)
> Edit /usr/local/ftds/interfaces file, for MSSQL, you have to add
an entry like the following*:
mssqlconnection
query tcp tds4.2 IPADDRESS_OF_SQL_SERVER 1433
* when writing PHP code, use the name "mssqlconnection" for hostname,
so you would use something like:
$conn = "mssqlconnection";
$username = "myuser";
$password = "mypass";
$dbc = mssql_connect ("$conn", "$username", "$password");
(7)
> Do a check to see if everything is OK, by starting Apache.
==============================================
What We Need ?
==============
* PHP Source (latest)
* FreeTDS (http://www.freetds.org/) get latest stable version
* Patience!!!
* Dual Login Mode in SQL Server Enterprise Manager
(Windows ONLY login will not work!)
Installation Procedure !
========================
(1)
> tar -xzvf freetds-xxx.tgz
> cd freetds-xxx/
> ./configure --prefix=/usr/local/ftds --with-tdsver=4.2 --enable-dbmfix
> make && make install
(2)
> Edit your /etc/ld.so.conf (or equivalant) add /usr/local/ftds/lib to it
> run ldconfig (located in /sbin/ldconfig in linux)
(3) GET READY TO HACK!!!
> tar -xzvf php-xxx.tar.gz
> cd php-xxx/
> edit 'ext/sybase/config.m4', replace 'dbopen' with 'tdsdbopen'
(in version 4.0.6 of PHP this in on line 27 of config.m4)
> (I am not sure if this step is 100% necessary, but do it anyway!)
edit the 'configure' file and look for PHP_SYBASE_DBOPEN, you should see two
different versions of this. As follows:
#define PHP_SYBASE_DBOPEN tdsdbopen <-- leave this alone
#define PHP_SYBASE_DBOPEN dbopen <-- change this to #define PHP_SYBASE_DBOPEN tdsdbopen
(4)
> ./configure [put other php options here] --with-mssql=/usr/local/ftds --with-sybase=/usr/local/ftds
> make && make install
> cp php.ini-dist /usr/local/lib/php.ini (the location of this file may differ for your installation)
(5)
> Now, edit /usr/local/lib/php.ini file, look for 'sybase.interface_file' directive
> uncomment it and change the value to /usr/local/ftds/interfaces (location where you installed freeTDS)
(6)
> Edit /usr/local/ftds/interfaces file, for MSSQL, you have to add
an entry like the following*:
mssqlconnection
query tcp tds4.2 IPADDRESS_OF_SQL_SERVER 1433
* when writing PHP code, use the name "mssqlconnection" for hostname,
so you would use something like:
$conn = "mssqlconnection";
$username = "myuser";
$password = "mypass";
$dbc = mssql_connect ("$conn", "$username", "$password");
(7)
> Do a check to see if everything is OK, by starting Apache.
解决方案 »
- 当在一个类中用 preg_replace 碰上了 $this时,悲剧发生了,请高手帮帮忙。
- 数据库表名的取法有关系么?
- 请教一个开源代码的法律问题
- 关于图片缓存的问题
- #Win2000Server + apache2.0.49 +php-4.3.5-Win32.zip ?
- 用PHP可不可以实现一个客户管理的管理程序
- 在登陆时加上验证码,怎么用程序来实现校验呢?
- 不用zend encoder,一样加密php明文.自己修改的php zend
- PHP file_get_content接收数据遗漏
- 请问,用Javamail发送的邮件能不能删除掉?
- 如何避免网页出现“警告:网页过期” 急!!!!
- 如何把数据导出变为excell文件呀
mssql用什么代替?
把
;extension=php_mssql.dll
前面的分号去掉
重启web服务器代码:<?php$Host='192.168.0.2';
$User='sa';
$Pswd='111';
$db='aa';
$db_table='admin';
$sql="SELECT * FROM admin";
//(1)打开并选择数据库
$connection =msslq_connect($Host,$User,$Pswd);
mssql_select_db($db,$connection); //(2)通过连接,在database name上运行查询
$result = mssql_query($sql,connection); //(3)当有结果集中还有行时
while($row = mssql_fetch_row($result))
{
(4)输出行中每个属性
for($i=0;$i < mssql_num_fields($result);$i++)
echo $row[$i] . " ";
} //(5)关闭数据库连接
mssql_close($connection);?>