views:

376

answers:

3

I have a PHP app running happily on the following system:

  • web app: PHP version 5.2.3
  • OS: Windows Server 2003 Standard 32 bit
  • database: SQL Server 2005 (express)
  • web server: IIS 6

I'm trying to get the same thing running on the following:

  • web app: PHP version 5.2.11
  • OS: Windows Server 2008 Standard 64 bit
  • database: SQL Server 2008 Standard 64-bit
  • web server: IIS 7

After doing the install and setup I usually do, phpinfo() is running but there is no MSSQL section. I've looked around and found some MS documentation to set up the system using a php_sqlsrv.dll and tried that but it seems to use a different interface to connect to the database (no more mssql_connect(), now it's sqlsrv_connect()). Is this the only way to connect php to SQL Server 2008 or do I just have the setup wrong? If I can go back to PHP 5.2.3 and have it work, that will be fine but I didn't want to undo what I have if it won't help.

Thanks,

+2  A: 

There is an extensive tutorial on MSDN on how to do this.

http://msdn.microsoft.com/en-us/library/cc793139%28SQL.90%29.aspx

Jonas Gorauskas
A: 

There should be a dll named php_mssql.dll in the ext folder of your php installation. You will want to make sure this is being loaded in your php.ini file with extension = php_mssql.dll . If that is not showing in phpinfo() after restarting the webserver it may be that you have installed the wrong thread safe version of PHP depending on how you've set things up with Fast CGI. You shouldn't have a problem using sqlsrv (SQL Server Driver for PHP). I would however recommend using version 1.1 of the driver as it has some improvements and supports SQL Azure. One thing you will notice is that datetime columns come back as PHP DateTime objects instead of strings. I've also noticed that you run into a lot less problems if you just install the stack with the Microsoft Web Platform Installer.

agentile
+1  A: 

The extension named php_mssql.dll is linked with an old Microsoft library (ntwdblib.dll). This library was last updated with MS SQL Server 6.5. It's a 32 bit library and does not support many of the new features introduced in newer versions of the database. It is possible to compile a version of the extension using FreeTDS. That will give access to the latest version of the TDS protocol. This also allows you to access SQL Server from a Linux/Unix based system.

The extension named php_sqlsrv.dll is developed and maintained by Microsoft gives much better support for the newer versions of SQL server and it should work in both the environments you describe.

fmk_ca