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.

解决方案 »

  1.   

    不是分数的问题啊上面的文章不是说得很清楚吗?这是从PHP Manual里面摘出来的
      

  2.   

    mysql中的 limit 20,40
    mssql用什么代替?
      

  3.   

    配置php.ini:打开php.ini

    ;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);?>