This is a long way from being a comprehensive troubleshooter. What I have tried to do here is to point you in the right direction to help you figure out why the script you are working with, doesn't. There is nothing worse than looking in your log files for the error, only to find 'premature end of script headers'. It doesn't tell you a whole lot, does it?
You don't have to receive the exact same error that I've used as examples here, but if you receive one similar then fixing it will be much the same. The main things you need to do to help debug a script are:
use carp to send errors to the browser
use die statements on any files/directories that get opened