简体   繁体   中英

php: odbc_connect(): SQL error

I have a big problem connecting my php page which is running on the same PC as my SQL Server with the SQL server and execute things...

Maybe this following warning will help you:

Warning: odbc_connect(): SQL error: [Microsoft][SQL Server Native Client 11.0]Named Pipes Provider: Could not open a connection to SQL Server [53]. , SQL state 08001 in SQLConnect in MY_CONFIG_FILE on line 9

I wonder what causes this problem as the webserver with the php page is running on the same machine as my SQL server does.

I´m using this code:

odbc_connect("Driver={SQL Server Native Client 11.0};Server='MY_IP';Database='MY_DATABASE';", 'MY_SQL_USER', 'THE_PW_OF_MY_SQL_USER');

What I have tried so far:

  1. Adding the IP to the host file of Windows
  2. Switching the complete firewall off
  3. adding a User-DSN ODBC Connection called SQLEXPRESS with a working connectivity test
  4. Connecting from my home PC with SQL Management Studio to the SQL Server. It worked with the same login data and IP which I´ve added in the SQL Config File.
  5. Enabling TCP/IP and Named Pipes in the SQL Management Studio on port 1433
  6. Restarting everything several times (Professional Solution, I know ;))
  7. enabling TCP/IP and Named Pipes in the cliconfg.exe

I hope there are some gurus here which can help me :)

Thx a lot in advance ;)

I´m sorry for the troubles.

The problem was, that I was using SQL Server Native Client 11.0 as driver. I switched it to SQL Server and now it works :/

Hopefully this at least helps someone, being in a similar problem....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM