Tag Archives: PHP

PHP Manager Fails to install on Windows 2016

Most of my web-dev projects are PHP based, and most of the data I work with is in MSSQL, so I end up using a combination of IIS + PHP + MSSQL pretty often. I just spun up my first Windows 2016 server, and promptly encountered issues installing PHP using Microsoft’s own Web Platform Installer tool (even using the latest version; 5.0 as of this writing). I was able to get PHP and the SQL drivers to install, but PHP Manager kept failing.

The fix: Change the registry key below from the default decimal value of 10 to a lower value; changing to 9 worked for me. Close regedit, re-run WPI and the installation will complete successfully. Go back into regedit and change the value back to 10 to prevent issues with future installations/updates of other IIS related apps that might check that value.

Edit: also make sure you have .Net 3.5 installed. WPI doesn’t prompt for it as a dependency, but the PHP Manager install will fail without it.

Edit v2: Apparently WPI should no longer be trusted for installing PHP Manager for IIS. Grab the MSI file for your version of IIS from this Git repo: https://github.com/edgardo001/PHPManagerForIIS-Versiones.

Share on Facebook

How to enable the display of all errors in PHP – at Runtime

If you’re like me, and love to develop in production, you can’t enable error reporting via your php.ini file – just add these two lines of code to your scripts and you’ll be drowning in notices, errors, and the like in no time:

Or, you can add the following config options to your .htaccess file:


Share on Facebook

Fix for MSSQL TEXT datatype being truncated to 4096 characters in PHP

The PHP MSSQL driver provided by Microsoft is set to limit the length of data returned from a MSSQL query in a TEXT datatype to 4096 characters. You can easily correct this by changing the following lines in your php.ini file (commented out by default):


Share on Facebook

PHP Headers to use for downloading a dynamically created CSV file

I don’t always browse the web, but when I do, I prefer Google Chrome (Side-note: If you don’t get the reference, spend more time on reddit.com). Unfortunately, some people still like using IE. Some code I wrote that worked great on Chrome and Firefox didn’t cooperate with IE. These headers seemed to work consistently whereas others (like leaving out the Pragma header) would result in IE throwing a ‘Cannot load this site’ error when the Save dialog would open. The StackOverflow forums have some other references in-case these don’t work for you.

Share on Facebook

PHP Function to strip everything except numbers from a string

Share on Facebook

Escaping special characters in PHP for MSSQL

PHP has a built-in function called mysql_real_escape_string() for use in MySQL queries but MSSQL has been left in the lurch for this one. I found this handy function on the StackOverflow forums that works like a charm (renamed for more uniform convention).

Share on Facebook

Win2008/IIS7 + PHP5 FastCGI = 404 Error Messages

Hopefully this saves someone some time. I spent hours working on a resolution before I came across it.

Background: Installed Win2008 + IIS7 + PHP 5.3 using the FastCGI method (used the Windows installer to configure IIS7).

Symptoms: PHP worked fine in my Default Site but when attempting to execute any scripts in Virtual Sites or Virtual Directories, every single PHP file would yield a 404 error message.

Solution: The problem ended up being that the ‘open_basedir’ config variable from the php config file is applied to ANYWHERE that PHP is run…regardless of what the actual home folder should be for a site (PHP picks up the basedir during installation and statically enters it in your php.ini file). The default ‘basedir’ will be whatever the root of your ‘Default Web Site’ in IIS is (usually c:\inetpub\wwwroot\). If you comment out this line (enter a semicolon before the line) and restart IIS, it will solve the problem. If you’re running PHP as a FastCGI module, you’ll actually have to rename (or copy) the php.ini file to a file named ‘php-cgi-fcgi.ini’ in the same folder as your php-cgi.exe executable. Be sure to restart IIS!

Share on Facebook