Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server PHP IIS

Ok, i'm having some trouble setting up SQL Server 2005 with PHP 5.2.17 on IIS 6.0.

I've installed all the drivers and the native clients as directed and my phpinfo() output contains the sqlsrv and the proper settings for it.

But, when I try to connect using this command:

sqlsrv_connect("address,port", array("UID"=>"un", "PWD"=>"pw", "Database"=>"db"));

I get the following error output:

Array
(
    [0] => Array
        (
            [0] => IMSSP
            [SQLSTATE] => IMSSP
            [1] => -49
            [code] => -49
            [2] => This extension requires either the Microsoft SQL Server 2008
Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Client O
DBC Driver to communicate with SQL Server.  Neither of those ODBC Drivers are cu
rrently installed. Access the following URL to download the Microsoft SQL Server
 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink/?Link
Id=163712
            [message] => This extension requires either the Microsoft SQL Server
 2008 Native Client (SP1 or later) or the Microsoft SQL Server 2008 R2 Native Cl
ient ODBC Driver to communicate with SQL Server.  Neither of those ODBC Drivers
are currently installed. Access the following URL to download the Microsoft SQL
Server 2008 R2 Native Client ODBC driver for x86: http://go.microsoft.com/fwlink
/?LinkId=163712
        )

    [1] => Array
        (
            [0] => IM002
            [SQLSTATE] => IM002
            [1] => 0
            [code] => 0
            [2] => [Microsoft][ODBC Driver Manager] Data source name not found a
nd no default driver specified
            [message] => [Microsoft][ODBC Driver Manager] Data source name not f
ound and no default driver specified
        )

)

The sqlncli.dll is in the windows/system32 folder and php_sqlsrv_52_ts_vc6.dll is in the php extensions folder and set to load in the php.ini.

I'm not sure why it's saying it requires the extension, when phpinfo says the extension is loaded and i'm also not sure why it is giving the ODBC Driver Manager error.

Any insight would be greatly appreciated.

========================================

Update/Edit: I tried using the following to connect and it worked just fine:

odbc_connect("Driver={SQL Native Client};Server=servername;Database=db", "un", "pw");

Is there a setting I could be missing in php.ini that could be preventing sqlsrv_connect from working properly?

like image 789
Wolftousen Avatar asked Jul 01 '26 23:07

Wolftousen


1 Answers

The sqlncli.dll is the SQL Native Client 2005 Try installing sqlncli10.dll (which is SNAC 2008) and see if that works. You can download it here (about 2/3 down the page): http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c6c3e9ef-ba29-4a43-8d69-a2bed18fe73c

-Brian

like image 156
Brian Swan Avatar answered Jul 04 '26 14:07

Brian Swan