locked
Cannot Integrate PHP, MS SQL Server 2000, and IIS 6.0 RRS feed

  • Question

  • I'm trying to integrate PHP (any version), MS SQL Server 2000, and IIS 6.0.  I've tried numerous combinations using different versions of PHP and different versions of the MS SQL Server driver for PHP.  Is there something obvious I'm missing?  I read the driver supports SQL Server 2000, but I'm not so sure now. Can someone tell me what would be the best version of PHP to use given I want to use IIS 6 and SQL Server 2000?

    Tuesday, December 14, 2010 6:06 PM

Answers

All replies

  • The SQLSRV driver does not support SQL Server 2000.

    See: http://msdn.microsoft.com/library/cc296172(v=SQL.90).aspx


    Ashay Chaudhary
    SQL Server Driver for PHP (http://blogs.msdn.com/sqlphp)
    All information provided "as-is" and without warranty.
    Tuesday, December 14, 2010 8:43 PM
  • I thought I read that SQL Server 2000 was supported by the native client, but have not tested it as we don't have any 2000 servers any more.

    Anyway, the easiest way to access SQL Server 2000 from PHP is with the built-in ODBC support in the Windows version.

    You don't need to configure any PHP extensions, just type your code and run it (assuming MDAC is installed).

    Here is an example:

    <?php
    header('Content-type: text/plain; charset=UTF-8');
    
    $connstr = "Driver={SQL Server};Server=MY_SERVER_NAME;Database=MY_DATABASE_NAME;";
    
    $conn = odbc_connect($connstr, "uid", "password");
    if ( $conn )
    {
    	$stmt = odbc_exec($conn, "select * from some_table");
    	if ( $stmt )
    	{
    		while ( ($row = odbc_fetch_array($stmt)) )
    		{
    			print_r($row);
    		}
    		odbc_free_result($stmt);
    	}
    	else 
    	{
    		echo 'Exec error: ' . odbc_errormsg();
    	}
    	
    	odbc_close($conn);
    }
    else 
    {
    	echo 'Connection error: ' . odbc_errormsg();
    }
    ?>

     


    Rob
    • Edited by Robert Johnson Wednesday, January 5, 2011 6:18 PM fix error
    Wednesday, January 5, 2011 6:16 PM
  • I'm using SQLSRV in production with SQL Server 2000 / Windows Server 2003 SP2 / IIS 6.0 / PHP 5.3.3.

    Not only that, but I have SQLSRV connecting to SQL Server 2000 under Apache 2.2.16 / mod_fcgid 2.3.5 on my development machine (XP SP3).

    I'm using the VC9 (non-thread safe) versions of PHP and SQLSRV.

    So, my experience says the native client supports SQL Server 2000, and SQLSRV works swimmingly with SQL Server 2000.

    Sample connect script:

    <?php 
    $server = 'myserver';
    $db = 'mydb';
    $uid = 'myuser';
    $pwd = '********';
    
    $connectionInfo = array("UID"=>$uid, "PWD"=>$pwd, "Database"=>$db);
    $conn = sqlsrv_connect( $server, $connectionInfo);
    if( $conn === false ) {
     echo "Could not connect.\n";
     die( print_r( sqlsrv_errors(), true));
    }
    
    $server_info = sqlsrv_server_info($conn);
    if( $server_info ) {
     echo "Server info:\n";
     echo "------------\n";
     foreach( $server_info as $key => $value) {
     echo $key.": ".$value."\n";
     }
    } else {
     echo "Error in retrieving server info.\n";
     die( print_r( sqlsrv_errors(), true));
    }
    
    echo "\n";
    
    if( $client_info = sqlsrv_client_info($conn)) {
     echo "Client info:\n";
     echo "------------\n";
     foreach( $client_info as $key => $value) {
     echo $key.": ".$value."\n";
     }
    } else {
     echo "Client info error.\n";
     die( print_r( sqlsrv_errors(), true));
    }
    
    sqlsrv_close( $conn);
    
    ?>
    

    Which returns:

    Server info:
    ------------
    CurrentDatabase: mydb
    SQLServerVersion: 08.00.2055
    SQLServerName: myserver
    
    Client info:
    ------------
    DriverDllName: sqlncli10.dll
    DriverODBCVer: 03.52
    DriverVer: 10.50.1600
    ExtensionVer: 2.0.1426.0
    

    -Ken

    • Proposed as answer by kismert Wednesday, January 5, 2011 9:53 PM
    • Edited by kismert Thursday, January 6, 2011 4:25 PM further specified PHP/SQLSRV version
    Wednesday, January 5, 2011 8:10 PM
  • Hello,

    Would you mind to tell us which version of  native client and SQLSRV good for working with MS-SQL Server 2000 ?

    Download link of them ?

    Thanks !

    Edward.

    Sunday, September 25, 2011 1:44 PM
  • Hi, i am using  IIS  6 , MSSQL SERVER 2000, PHP Version 5.3.6 NTS.

     

    install  the native client for MSSQL 2008 R2 (on the php server  )

         http://download.microsoft.com/download/B/6/3/B63CAC7F-44BB-41FA-92A3-CBF71360F022/1033/x86/sqlncli.msi

    download the microsoft drivers for PHP ( copy the DLLs to extension dir)

    modify you php.ini 

     

    //use Full path (do not use  extension_dir ="ext")

     extension_dir = "C:\Program Files\php\ext" 

     

    //enable mssql ext..

     

    extension=php_pdo_sqlsrv_53_nts_vc9.dll
    extension=php_sqlsrv_53_nts_vc9.dll

    that work perfectly..

    sorry my english

     

     

     

    Monday, October 10, 2011 11:20 PM