• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3282
  • Last Modified:

Call to undefined function mssql_connect() error in new PHP install

I am trying to set up PHP on a Windows 2003 Server box to communicate with a SQL Server 2005 install on the same box.  I have taken the following steps in installing PHP

2)      Extract PHP zip file to C:\PHP
3)      Copy php.ini_recommended to PHP.ini
4)      In PHP.ini take the ; off the beginning of the line extension=php_mssql.dll
5)      Put C:\PHP in path environment variable
6)      Under Properties for the web site in IIS, go to Home Directory tab and
              a.      chance Execute permissions to Scripts Only
              b.      Click Configuration Button
                            i.      On the mappings tab, click Add .  Executable is C:\php\php.exe and the extension is .php
7)      Copy ntwdblib.dll and php_mssql.dll to C:\PHP and C:\Windows\System32
8)      Reboot server fully

Now when I try to connect to the server I get the above error.  I have added this script:

if (function_exists('mssql_connect')) {
      echo "Okay, fn is there";
} else {
      echo "Hmmm .. fn is not even there";

and I get the "fn is not even there" message.

Can someone help, please???
1 Solution
You need to copy the created php.ini to your c:\windows directory or the directory given in your phpinfo()-Output for "Configuration File (php.ini) Path" Then restart the webserver and try again
>>>7)      Copy ntwdblib.dll and php_mssql.dll to C:\PHP and C:\Windows\System32
make sure php_mssql.dll is in extension directory and you have the right path set to the extensions directory in php.ini

Also make sure that you set environment variable for the systems...and reboot your box.

Cross posted to another question (http://www.experts-exchange.com/Database/MySQL/Q_23135294.html), but I'll state the same thing here:

Don't put anything in your system32 folder. It isn't the correct way to setup php and can cause problems later. Instead, put your ntwdblib.dll file in your c:\php folder, and put php_mssql.dll in the C:\php\ext folder.

Make sure you have done the following:

1) You should put the C:\Program Files\PHP folder in the system path. To add the folder to your path:

Right click on my computer->properties
advanced tab
click "environment variables"
under system variables ( the bottom box ) select "path". click "edit"
This is a semicolon delimited list of paths. Add C:\Program Files\PHP to it. The last item should have a semicolon on the end.
Reboot the computer for changes to take effect.

PHP_MSSQL.dll is an extension. It should be in C:\PHP\Ext, and configured in the php.ini file.

In your php.ini, you should have your extension loaded in the "Dynamic Extensions" section:

; Dynamic Extensions ;

And also, your EXTENSION_DIR should be set to the extension directory in your php folder. e.g.:

extension_dir ="C:\PHP\ext"


Finally, make sure you are editing the CORRECT php.ini. Call phpinfo(); from any php page to output a whole pile of information about php. In there it should state which ini file is being used. OFTEN PHP USES C:\WINDOWS\PHP.INI, and not the php.ini in the c:\php.ini folder.

Also remember, before any changes take effect, you need to restart the php and IIS services. Better would be for you to restart your entire computer. It doesn't just take effect automatically. So before you test, restart the computer.
thearniecAuthor Commented:
Thank you for your help, it worked instantly!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now