Windows IIS, PHP & Error 500: The page cannot be displayed because an internal server error has occurred.

I was pulling my hair out this morning when I transferred my PHP Content Management System to an Windows IIS Shared Server and started getting the message Error 500: The page cannot be displayed because an internal server error has occurred.

Debugging wasn’t working, there were no syntax errors, I was stumped. So I started breaking down the code into little modules to test.

I tried printing out a variable that wasn’t initialised and low and behold the dreaded error appeared.

echo $test;

If I initialised the variable first there were no problems i.e.

$test¬† =¬† “Hello, World!”;
echo $test;

So, basically, the problem was that php was spitting out some debug warnings, however the shared hosting account was interpreting this as an internal error and hence the error message on the client browser.

An ideal fix would be to get rid of all warnings from the code, however, a quick workaround was to simply turn off error reporting altogether using the following line of code:

error_reporting(0);

Hope this helps someone out there!

Leave a Reply

Your email address will not be published. Required fields are marked *