Issues with PHP & MSSQL

I am trying to get PHP to talk to MSSQL on a Windows 2003 server. I have this simple code on a page:

<?PHP $link = mssql_connect('xxxxx', 'xx', 'xxxxx'); mssql_select_db('xxxxx', $link); ?>

and I am getting this error when I run the page.

Fatal error: Call to undefined function mssql_connect() in .php on line 3

I also tried this code to see if the functions are on:

<? if (function_exists('mssql_fetch_row')) { echo "MSSQL functions are available.
n"; } else { echo "MSSQL functions are not available.
n"; } ?>

and that returns “MSSQL functions are not available”.

I have made sure that the MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini. I also copied the ntwdblib.dll file into the winntsystem32 directory. I have also rebooted numerous times.

Here is all the info about my setup:

Windows 2003 Server
MS SQL Server 2005
PHP 5.2.5
IIS 6.0

Any help on this would be great. I am very new to PHP and it is driving me crazy.

Thanks in advance.

The extension requires the MS SQL Client Tools to be installed on the system where PHP is installed. The Client Tools can be installed from the MS SQL Server CD or by copying ntwdblib.dll from winntsystem32 on the server to winntsystem32 on the PHP box. Copying ntwdblib.dll will only provide access through named pipes. Configuration of the client will require installation of all the tools.

Requirements for Unix/Linux platforms.

To use the MSSQL extension on Unix/Linux, you first need to build and install the FreeTDS library. Source code and installation instructions are available at the FreeTDS home page: »

Note: In Windows, the DBLIB from Microsoft is used. Functions that return a column name are based on the dbcolname() function in DBLIB. DBLIB was developed for SQL Server 6.x where the max identifier length is 30. For this reason, the maximum column length is 30 characters. On platforms where FreeTDS is used (Linux), this is not a problem.

The MSSQL extension is enabled by adding extension=php_mssql.dll to php.ini.

To get these functions to work, you have to compile PHP with --with-mssql[=DIR], where DIR is the FreeTDS install prefix. And FreeTDS should be compiled using --enable-msdblib.

More info at

Sponsor our Newsletter | Privacy Policy | Terms of Service