This error is occuring because xhtml generated by your script is not valid.If you are confused with what kind of error it is you can see the source code on browser or use any online xhtml validator(google it).If you can't figure out the problem then you can change the DOCTYPE to xhtml transitional or html 4.
Else posting source code of html generated here is not a bad idea.So others can help you.