One of the best places to look for errors is in the server logs, if you have access to them. That depends on your host.
For PHP you can insert the following code at the beginning of your file:
error_reporting(E_ALL);
ini_set('display_errors','on');
Everything  that goes to the server log will also show up on your web page. Be sure  to remove this ASAP as it could be annoying to general readers and it  could give away key information.
Another  good trick is to use echo/alert statements in key parts of your code to  give you an idea of what is going on. (You could also create a log file  on your server, but that's getting pretty elaborate). Again, remove  ASAP.
A  word of caution with the use of echo in PHP. Some PHP processing is  messed up when there's anything sent to the browser before it finished.  Doing things with headers, for instance. That goes south with any  output.