Thanks to everyone who has replied with useful advice. I will try debug_backtrace, which may help me with my current problem. I wasn't aware of this function.
I can see the sense of trying to debug this stuff on a local server before up-loading it, but to be a worthwhile test/debug environment I guess I'd have to have the same or similar versions and configurations of PHP, MySQL, Zend and maybe lots of other things which are running on TCH, and that's gonna take me a long time to learn. I was hoping that I'd be able to debug it running "for real" on TCH, and in fact I've made quite a lot of progress before running into my current problem.
Are there any other tools or functions (in addition to debug_backtrace) that I ought to know about which can help in debugging PHP code without root access? Or any tutorials or white papers on this?
Thanks all for your help.
Rowan