PHP connection to SQLServer2005 problem solution

  • 2020-03-31 20:56:14
  • OfStack

Later fire, in the virtual machine installed on WIN2003 a try, load MSSQL module is no problem, but with mssql_connect("localhost", "sa", ""); But how also can't connect to the database, and then the Internet looked up a lot of information, finally done:


Environment: IIS6.0+PHP5+SQL Server2005

When installing SQL Server, choose the mixed login mode, namely Windows and SQL Server authentication mode.

Steps:

1. First configure PHP5 connection to MS SQL Server as usual

Open the extension=php_mssql.dll option in php.ini. Remove)

2. Download the correct version of ntwdblib.dll (2000.80.194.0)
3. The cover c: Windows \ system32 \ ntwdblib DLL
4. Overwrite PHP \ntwdblib.dll (sometimes if this step is not successful, put php5ts.dll that PHP depends on in the system32 directory)
5. Run SQL Server Configuration Manager: SQL Server Configuration Manager, and open the protocol
6. Allow named pipes and TCP/IP
7. Right click on "TCP/IP" to open the Properties TAB "IP addresses"
8. Fill in 1433 at "TCP Dynamic Ports" (after testing, it is not possible to fill in 1433 here)
9. Restart SQL Server, IIS, and PHP

Mssql_connect ("localhost,1433", "sa", ""); I tried it, but I don't have to.


Some people on the Internet said that they wanted to change the mssql.secure_connection = Off in the php.ini configuration file to on. As a result, after I changed the mssql.secure_connection = Off, I failed to connect to SQL Server for a long time.

Related articles: