Home >Backend Development >PHP Tutorial >Solution to the problem of PHP connecting to SQLServer2005_PHP tutorial

Solution to the problem of PHP connecting to SQLServer2005_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:35:201051browse

Later, it became popular. I installed WIN2003 on a virtual machine and tried it. There was no problem loading the MSSQL module, but I couldn't connect to the database using mssql_connect("localhost", "sa", "");. Later, I searched a lot online. Information, I finally got it:


Environment: IIS6.0+PHP5+SQL Server2005

When installing SQL Server, select the mixed login mode, that is, windows and sql server authentication mode .

Steps:

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

Open the extension=php_mssql.dll option in PHP.ini (that is, change the previous; number removed)

2. Download the correct version of ntwdblib.dll (2000.80.194.0)
3. Overwrite c:windowssystem32ntwdblib.dll
4. Overwrite phpntwdblib.dll (sometimes this step is done If it fails, put the php5ts.dll that PHP depends on in the system32 directory)
5. Run SQL Server Configuration Manager: SQL Server Configuration Manager, open the protocol Protocols
6. Allow named pipes "named" pipes" and "tcp/ip"
7. Right-click "tcp/ip" and open the Properties tab "IP addresses"
8. Fill in 1433 in the TCP dynamic port "TCP Dynamic Ports" (tested, In fact, you can leave it blank here)
9. Restart SQL Server, IIS and PHP

10. Use host name + port number to connect, mssql_connect("localhost,1433", "sa", " "); (I tried it and it worked without it)


Some people on the Internet said that they should change mssql.secure_connection = Off in the php.ini configuration file to on, but after I changed it , I couldn't connect to SQL Server after trying for a long time. Then I tried to change mssql.secure_connection = Off back to Off, and finally connected.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322238.htmlTechArticle Later it became popular. I tried installing WIN2003 on the virtual machine. There was no problem loading the MSSQL module, but using mssql_connect ("localhost", "sa", ""); But I couldn't connect to the database. Then I checked online...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn