SQL Server PHP IIS

Well, I am having trouble setting up SQL Server 2005 from PHP 5.2.17 to IIS 6.0.

I installed all the drivers and my own clients as directed, and my phpinfo () output contains sqlsrv and its corresponding settings.

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
        )

)

sqlncli.dll is located in the windows / system32 folder, and php_sqlsrv_52_ts_vc6.dll is located in the php extension folder and loaded into php.ini.

I'm not sure why he says an extension is required for this when phpinfo says the extension is loaded, and I'm also not sure why it gives an ODBC manager error.

Any understanding would be greatly appreciated.

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

Update / Edit: I tried using the following to connect, and it worked simply:

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

, php.ini, sqlsrv_connect?

+3
3

sqlncli.dll - SQL Server 2005. sqlncli10.dll( SNAC 2008) , . ( 2/3 ): http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c6c3e9ef-ba29-4a43-8d69-a2bed18fe73c

-

+1

, SQL Server, . Enterprise Manager Management Studio a > , SQL Server, Windows Authentication.

0

, , .

, sqlncli.dll.

Process Monitor

http://www.iislogs.com/articles/processmonitorw3wp/

Then I saw that the w3wp.exe process got access to this registry key

HKLM \ Software \ ODBC \ ODBCINST.INI \ Native SQL Client 10.0

I opened RegEdit and went to this key.

I right-click → Permissions and added the network service to the list and gave it read permissions.

The application pool has been restored, and now it works!

Hope this helps!

Cheers, Fedya

0
source

Source: https://habr.com/ru/post/1790038/


All Articles