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?
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:
http://php.net/manual/en/book.mssql.php

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: » http://msdn.microsoft.com/en-us/sqlserver/ff657782.aspx.
0
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.
http://php.net/
1
systechadminConsultantCommented:
Refer http://php.net/manual/en/function.sqlsrv-begin-transaction.php

and enable SQL support in PHP.ini file
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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:  https://msdn.microsoft.com/library/cc296172.aspx   You can download version 2.0 (SQLSRV20.EXE) from this page:  https://www.microsoft.com/en-us/download/details.aspx?id=20098

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.
0
Sheldon LivingstonConsultantAuthor Commented:
I have upgraded to PHP 5.5.26 and installed SQL drivers 3.2 and rebooted the server.

Still no change...
0
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'?
0
Sheldon LivingstonConsultantAuthor Commented:
I installed Driver 11...

I add this to the php.ini:

extension=php_pdo_sqlsrv_56_nts.dll

I now get a "Call to undefined function sqlsrv_connect()" error.
0
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.
http://php.net/manual/en/sqlsrv.setup.php
0
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.
0
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.
0
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).
0
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!
0

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.
0
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.
0
Sheldon LivingstonConsultantAuthor Commented:
Finally got it
0
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.

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.