Here are some common problems and solutions you may find useful once you start scripting with PHP.

Turn on error reporting

If you're having problems, one of the first things may want to do is enable error reporting. Error reporting takes a lot of the guess work out of debugging your code and should give you a good place to start. To turn on error reporting, include these lines of code at the top of your PHP script.


Note: Remember to turn off error reporting once you have fixed your issue. Leaving it enabled may show unwanted output to your visitors.

Broken Syntax

Often problems with PHP code are cause by something very simple. Check your syntax and look for broken code highlighting (if your editor supports it).

PHP code being displayed instead of running

If you're code is being displayed on your website instead of running make sure all your files are saved with the .php extension. Another possible reason for this is that PHP is not enabled on your hosting. We don't enable PHP on our Starter hosting package, so if you wish to run PHP and are using this package you will need to upgrade.

Incompatible PHP version

Most scripts are compatible across different versions of PHP, however sometimes as PHP is upgraded things are changed slightly and will not always be backwards compatible. Because of this it's always a good idea to know what version of PHP to code for.

PHP page loads continuously

If you're using loops within your PHP code you may run into problems where by your script seems to never stop loading. A common cause of this problem is that the loop isn't counting properly.

One way to debug this is to echo() the current count number at the beginning of each loop cycle, this will hopefully give you a better idea of where the problems lies.

If you're not using loops and your page is continuously loading you should double check any HTML or Javascript code.

Advanced troubleshooting and PHP knowledge sharing

We highly recommend the very active discussion forum (PHP Builder) for discussing all aspects of PHP -

Need a hand? Search over a hundred step-by-step support guides