Sheldon Livingston
asked on
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.
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.
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/
http://php.net/
Refer http://php.net/manual/en/function.sqlsrv-begin-transaction.php
and enable SQL support in PHP.ini file
and enable SQL support in PHP.ini file
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.
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.
ASKER
I have upgraded to PHP 5.5.26 and installed SQL drivers 3.2 and rebooted the server.
Still no change...
Still no change...
Did you also install the Microsoft ODBC Driver 11 that is required? And did you add the 'sqlsrv' extensions to your 'php.ini'?
ASKER
I installed Driver 11...
I add this to the php.ini:
extension=php_pdo_sqlsrv_5 6_nts.dll
I now get a "Call to undefined function sqlsrv_connect()" error.
I add this to the php.ini:
extension=php_pdo_sqlsrv_5
I now get a "Call to undefined function sqlsrv_connect()" error.
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
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
ASKER
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.
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_
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();
Just a stylistic comment... You might want to include all of the "extension=xxx" lines in the same part of php.ini.
ASKER
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).
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).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.
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.
'sqlsrv_connect()' is probably part of "extension=php_sqlsrv_56_n ts.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.
ASKER
Finally got it
http://php.net/manual/en/book.mssql.php
In the Introduction, we have this: