Can you post your code (or a fragment of the code you think is causing the problem) so we can have a look at it? Without looking at your code, we can only guess what is happening.
You should check the Apache error.log to see what is causing this error. The error log usually showes the error in detail.
You can also run the script at the command-line to see if you can get the HTML you expected.