Jump to content

Recommended Posts

I have many web applications I've written over the years currently on a Windows 2003 server running IIS6 and PHP4.

 

Our SQL server is a Microsoft SQL server 2008.

 

PHP4 came with mssql module, all I had to do back then was uncomment the mssql section of php.ini and it was good to go.

 

The old server is still up and running and functioning, but I'm trying to set up a new server with PHP5 and move all of the web applications over to it.

 

I'm a bit confused as to which version of PHP I should install, whether VC6 or VC9, thread safe or non-thread safe and whether I should install it as CGI or Fast-CGI module.

 

I did eventually get PHP installed. However PHP5 does not come bundled with MS SQL.

 

After some searching I found a Microsoft SQL driver for PHP. However the syntax is class based, and all of my old code is function based. I was able to get this to work with the database, however there is a LOT of code I would have to change in order to move the applications over.

 

TLDR:

Is there a way to install PHP5 on IIS with a module that uses the old mssql functions (as opposed to the class based driver issued by Microsoft) to interact with MS SQL Server 2008 so that I can simply copy my applications over instead of having to rewrite all of the code that interacts with the database?

 

- Wasn't sure if this should go in MS SQL or Installation forums, please move if necessary.

jjmac-

 

If you are moving to PHP5, I would suggest that you bite the bullet (as tough as it might be) and move to the sqlsrv driver (the SQL Server Driver for PHP). The old mssql driver is based on obsolete dblib technology (more about that here: http://blogs.msdn.com/b/brian_swan/archive/2010/03/08/mssql-vs-sqlsrv-what-s-the-difference-part-1.aspx). The good news is that the 2.0 release of the sqlsrv driver comes in two flavors: the SQLSRV driver (which is a "function-based" or "procedural" driver) and the PDO_SQLSRV driver (which supports PDO and is object-oriented). So, you shouldn't have to make the jump to using classes if you don't want to. The bad news is that there isn't an easy way (that I know of) to install PHP 5 with support for the old php_mssql.dll driver. Hopefully, this blog post will help convert to the sqlsrv driver: http://blogs.msdn.com/b/brian_swan/archive/2010/03/10/mssql-vs-sqlsrv-what-s-the-difference-part-2.aspx.

 

On the question of CGI vs. Fast-CGI, definitely go with Fast-CGI (the CGI module spins up a new PHP process for every incoming request!). Performance with Fast-CGI is much better. One easy way to get this all set up is to use the Web Platform Installer (installs PHP, sqlsrv driver, SQL Server Express, etc...and configures everything). Check it out here: http://www.microsoft.com/web/downloads/platform.aspx. One drawback of the WPI is that it installs PHP 5.2.14, not PHP 5.3 (which has tons of Windows optimizations). The question of VC6 vs VC9 only comes into play (I think) if you are running PHP 5.3...in which case you should go for VC9. If you want to go with PHP 5.3, you'll have to install/configure it manually: http://php.net/manual/pl/install.windows.iis7.php.

 

I hope that helps. Let me know if you have more questions.

 

-Brian

Thanks so much, very valuable information for me. I do a lot of web application development, but not much on the server and installation side of things so I really appreciate the information!

 

WPI looks to be something I'll be very interested in, even if it doesn't have PHP 5.3. I have a question about WPI, do you know if they release updates? For instance at some point will I be able to update to 5.3 via WPI?

I tried out Microsoft Web Platform Installer and it worked great. Started playing around with the sqlsrv functions and it looks like it's not going to be that bad to convert my old apps to use this driver -- Not as bad as converting them to class based anyway. Find and replace will take care of most of it it looks like, aside from the db connections.

 

Thanks again for the help!

I came across a comment on the PHP web site under documentation for mssql_connect today that addressed my specific problem exactly:

 

If you have an application which requires MSSQL as interface (and not the new SQLSRV) you have to look for an alternative method. The old (now rightly unsupported) way from Microsoft does not work with PHP 5.3.

After spending several days and nights with trying to connect

here is an easy solution which worked great with all applicatins expecting mssql: FreeTDS for Windows. Here is a great how to with installer links on the Moodle site: http://docs.moodle.org/en/Installing_MSSQL_for_PHP

 

Couple of hints:

- Make sure you have set up a user with "SQL SERVER authentication" who has rights to connect.

- Also make sure after you install and still have problems to run PHPinfo and check that you find the below:

 

PHPINFO: mssql

MSSQL Support enabled

...

Library version  FreeTDS

 

That works perfect for me on Windows 2003 with IIS6 and PHP 5.3 (non threadsafe, VC9).

Hope this is helpful

 

I followed the instructions on http://docs.moodle.org/en/Installing_MSSQL_for_PHP to install php_dblib.dll, copied one of my apps over to the new server and it ran exactly as expected with no change to the code.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.