PHP on Server 2008 R2 SQL Server 2012

Trying to get PHP to work on a Server 2008 R2 SQL Server 2012 machine.

Echo works... so basic PHP is working (version 5.3.28).

I've created a db and am trying to query it and am getting a "Call to undefined function mssql_query()" error message.

Please help... I don't know what more details are needed.
Sheldon LivingstonConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
PHP has online documentation for all its extensions. Check the links here:

In the Introduction, we have this:
This extension is not available anymore on Windows with PHP 5.3 or later.

SQLSRV, an alternative extension for MS SQL connectivity is available from Microsoft: »
Ray PaseurCommented:
Sidebar note... PHP 5.3 is obsolete and not supported any more. The current releases that you should be using are listed under "Download" on the home page.

and enable SQL support in PHP.ini file
Acronis True Image 2019 just released!

Create a reliable backup. Make sure you always have dependable copies of your data so you can restore your entire system or individual files.

Dave BaldwinFixer of ProblemsCommented:
You probably need to download the appropriate Microsoft PHP drivers and the SQL Native Client to go with them.  More info here:   You can download version 2.0 (SQLSRV20.EXE) from this page:

The host for my own website emailed me to say that they were upgrading the server software and will be running PHP 5.3.10 now because that's what comes with the newer version of Linux that they are installing.   I have a couple of customers that are running PHP 5.4 on their hosting but none newer than that.
Sheldon LivingstonConsultantAuthor Commented:
I have upgraded to PHP 5.5.26 and installed SQL drivers 3.2 and rebooted the server.

Still no change...
Dave BaldwinFixer of ProblemsCommented:
Did you also install the Microsoft ODBC Driver 11 that is required?  And did you add the 'sqlsrv' extensions to your 'php.ini'?
Sheldon LivingstonConsultantAuthor Commented:
I installed Driver 11...

I add this to the php.ini:


I now get a "Call to undefined function sqlsrv_connect()" error.
Ray PaseurCommented:
Often this can result from an errant directory path structure.  Here are some ideas:

Use phpinfo(); to verify that the extension is installed

Make sure you modified the correct version of php.ini, ie, the version that is actually loaded by PHP

Check the PHP error logs to see if additional information is available

Check the links here for information on installing and configuring.
Sheldon LivingstonConsultantAuthor Commented:
How do you "Use phpinfo(); to verify that the extension is installed"?

I open IIS and then the PHP Manager.  The PHP Manager shows PHP version 5.5.26.

I had "Registered new PHP version" by navigating to the php-cgi.exe file.  The php-cgi.exe file was sitting in the "C:\Program Files (x86)\PHP\v5.5" directory where I placed it.

The "Configuration file" shows it's in the "C:\Program Files (x86)\PHP\v5.5" directory.

After installing driver 3.2, the php.ini file had "[PHP_SQLSRV_56_NTS]" listed as the last line.  So, I guessed that this meant that I should include "extension=php_pdo_sqlsrv_56_nts.dll" under it.
Ray PaseurCommented:
How do you "Use phpinfo(); to verify that the extension is installed"?
Run this script, shown here in its entirety, and scan the output with your browser's "find" functionality to locate key words or phrases.
<?php phpinfo();

Open in new window

Just a stylistic comment... You might want to include all of the "extension=xxx" lines in the same part of php.ini.
Sheldon LivingstonConsultantAuthor Commented:
I am beginning to think that this isn't worth it.  

Typically I'd use BlueHost and be done with it, but this project needs exe's to be able to be ran on the server... thus we got our own server.  We got a MS server due to needing to run the exe files, some that will be custom made, and I don't have the years needed to do this with a Linux machine.

So, I decided on a MS server, using php, with a MS SQL.  After spending days on just trying to connect to a database I thought I'd install change the plan and try MySQL.  

By the way, this issue has progress to a "Call to a member function fetch_assoc() " which means that I can now connect to the db and query it (I think) but there appears to be a whole different language/syntax needing to be learned to try and get the most basic website running if using PHP and MSSQL.

So, MySQL 5.6 is installed.

Of course there isn't a GUI for MySQL (that would be too easy) so now that mucks things up...

So I think that it is time to spend (too much) time and see if there is any way to get a website going on a MS server, that I own, with PHP using MySQL (with a gui for MySQL).
Ray PaseurCommented:
If you've gotten to the point that you have error messages from MySQL member functions, then we are probably well past the initial question.  Suggest you close this one out and open a new one with the code example that shows how you got the "Call to a member function fetch_assoc() " message.

FWIW, most of these messages come with line numbers, so you can know exactly where the issue was captured.  Knowing what to do to fix it is a different thing, and we can help with that!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Sheldon LivingstonConsultantAuthor Commented:
I was kind of thinking this and yes I'm aware of line numbers.

I essentially just copied some standard PHP code to authenticate a user and was using this code to test the PHP/MS SQL implementation.  As you are probably aware we are not talking about that intense of a set of PHP code yet it has turned into something monstrous.

I guess it makes sense that there are different syntax's when hitting MySQL vs MS.

Perhaps I should just look for a reference of some sort and stick with the original plan.
Dave BaldwinFixer of ProblemsCommented:
'sqlsrv_connect()' is probably part of "extension=php_sqlsrv_56_nts.dll" and not the PDO version "extension=php_pdo_sqlsrv_56_nts.dll"   And yes, it does take more to get the 'sqlsrv' extension running under PHP than it does the 'mysql' extension.  More details to be taken care of.
Sheldon LivingstonConsultantAuthor Commented:
Finally got it
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.