Home > Backend Development > PHP Tutorial > Why am I getting a 'Call to undefined function mssql_connect()' error when connecting to SQL Server in PHP?

Why am I getting a 'Call to undefined function mssql_connect()' error when connecting to SQL Server in PHP?

Patricia Arquette
Release: 2024-11-12 12:13:02
Original
665 people have browsed it

Why am I getting a

PHP Fatal Error: Call to Undefined Function mssql_connect()

Problem:

When trying to connect to a SQL Server 2008 instance using PHP 5.3 on IIS7 and Windows Server 2008, you may encounter a fatal error: "Call to undefined function mssql_connect()."

Solution:

You are likely using the incorrect function for your PHP configuration. Here's what you need to do:

1. Ensure the SQLSRV Extension is Enabled:

Confirm that the SQLSRV extension is properly installed and enabled in your php.ini file:

extension=php_sqlsrv_53_nts.dll
Copy after login

2. Use the Correct Function:

You have installed Microsoft's SQLSRV extension, which requires the use of sqlsrv_connect() instead of mssql_connect().

Additional Troubleshooting:

  • Extension_dir Setting: Make sure that extension_dir in php.ini points to the correct directory where the SQLSRV extension is located.
  • Restart the Server: After making any changes to php.ini, remember to restart the web server (IIS) for the changes to take effect.
  • PHP Version: Ensure that the PHP version running on your server matches the version of the SQLSRV extension you are using.
  • API Documentation: Refer to Microsoft's SQLSRV_Help.chm for detailed API documentation on the sqlsrv_connect() function and other related functions.

The above is the detailed content of Why am I getting a 'Call to undefined function mssql_connect()' error when connecting to SQL Server in PHP?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template