Solution to the error when php connects to sqlserver: 1. Open php.in and remove the comment symbol of extension=php_mssql.dll; 2. Find the ntwdblib.dll file; 3. Run SQL Server Configuration Manager and set it Just use the port.
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if there is an error when connecting to sqlserver with php?
About the problem of php connecting to sqlserver
Some points that should be paid attention to when using php to connect to sqlserver2000
1. Configure php
a. Open php.in and remove the comment symbol of extension=php_mssql.dll.
b. Open php.in. If your program and database are on the same server, please change mssql.secure_connection = Off to on. If they are on two servers, please change it to off, otherwise it will report Errors such as "Login failed for user (Null)".
c. Copy php_mssql.dll to the directory specified by extension_dir in php.in or the system system32 directory. (php_mssql.dll is included in the compressed installation package of php).
2. Pay attention to the ntwdblib.dll file
a. Find the ntwdblib.dll file in the system32 directory of the server where sqlserver2000 is installed, check its version through the properties, and then use this as the standard Overwrite the corresponding files in the php directory of the program server.
b. The corresponding files under apache2/bin also need to be overwritten! (Many people can't connect because they didn't notice this step, and so did I)
After completing the above steps, you need to restart apache.
Note: In actual use, it was found that if you manually install php to iis through a php compressed file, you must restart the machine and not just iis.
3. Configure sqlserver
a. Run SQL Server Configuration Manager: SQL Server Configuration Manager, open Protocols
b. Allow named pipes "named pipes" and " tcp/ip"
c. Right-click "tcp/ip" and open the Properties tab "IP addresses"
d. Fill in 1433## in the TCP dynamic port "TCP Dynamic Ports"
#e. Restart SQL Server---------------------------------- --------------- ---------------------------------- ----------4. Use the following method to connect to MS SQL Server 2005: The code is as follows:<?php //链接数据库 $conn=mssql_connect('localhost','sa','123456'); mssql_select_db('gu_dde',$conn); //query语句 $Query="select * from dde_top"; $AdminResult=mssql_query($Query); //输出结果 $Num=mssql_num_rows($AdminResult); for($i=0;$i<$Num;$i++) { $Row=mssql_fetch_array($AdminResult); echo($Row[1]); echo("<br/>"); } ?>You can see these functions and MySQL The functions are all corresponding and very convenient to use! -------------------------------------------------- ----------------------------5.FAQ Frequently Asked Questions:1Error Report:Fatal error: Call to undefined function mssql_connect()Solution:Use MSSQL_series functionsTo use both of these, you need to configure php.ini Make settings: (1) To allow DCOM, you need to remove the semicolon ";" before ;com.allow_dcom=TRUE in php.ini. (2) To use MSSQL extension, you need to remove the semicolon ";" before ;extension=php_mssql.dll in php.ini. (Key)(3) Confirm extension_dir is the correct path, take this machine as an example: extension_dir = "c:\AppServ\php5\ext". (4) If the machine still reports an error saying that c:\AppServ\php5\ext\php_mssql.dll cannot be found but this file obviously exists. Solution: Copy php_mssql.dll and ntwdblib.dll to the system directory \system32 and restart the test. . (Note: The above two dll files are not in the same directory, mine is c:\AppServ\php5\ext\php_mssql.dll; c:\AppServ\php5\ntwdblib.dll) Also copy ntwdblib.dll to the apache2/bin/ directory! Also remember to restart the server after setting it up. 6. Other questions:If php apache Sql Server2000 is on the same machine, there will be basically no problem accessing it. If the Sql Server2000 and PHP machines are separated, you need to confirm that the machine name of the machine where the SQL Server is located can be pinged. If it cannot be passed, modify the hosts file under \system32\drivers\etc of the PHP machine and add a line. The machine IP of the machine where sqlserver is located. The machine name of the machine where sqlserver is located. If you still cannot access it, you need to confirm whether the machine where php is located has a secret conversion to mdac. How about simply installing the sqlserver client. Recommended learning: "
PHP Video Tutorial"
The above is the detailed content of What to do if there is an error connecting php to sqlserver. For more information, please follow other related articles on the PHP Chinese website!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools