PHP produces an error_log file in its directory whenever a problem occurs, you can find debug information there.
Also, try using var_dump($someVarible). This will give you useful information about the current state of a variable - often better than echo.