How can I find out why my PHP script isn't working?

There are general guidelines to help you in the PHP documentation and a number of PHP forums. You should read those first.

A quick way to investigate why your PHP isn't working is to turn on PHP tracing. You can do this by editing your /usr/local/lib/phpn.ini file. If you don't have this file, refer to the PHP INSTALL file, which provides a template .ini file.

Ensure error_reporting is set to 7 and log_errors is set to On. Set error_log to the name of a file, for example, /tmp/php_errors. Once you have made these changes, restart Apache and all the normal errors, warnings, and parser errors get logged to this file.

You can also set track_errors to On, which adds the most recent error to the $php_errormsg variable.