yea... generally a decent idea for the php code I've written is to have a $debug variable at the top of the file that you can toggle (1/0) depending on if you want to print/echo a bunch of other variables... so for example, my code is littered with statements like this:
if ($debug) echo ("var: " . $var . "\n");
you may throw in some formatting to make it look better and more readable, like i did above.... hope this helps, and in the future, documentation always helps debugging too.
Sorry for the lecture, but hope you get things working!!!
Have fun,
cappaberra