This is such an annoying problem!
The text that I posted above is the result from the PHP code which does not validate properly (the SMGL thing).
I try to validate the code after I paste it in a new text document and save it (using BBEdit) and that doesn't work.
BUT if I then open it in Dreamweaver and go save-as the file will then parse correctly on the W3C validator.
Also I have noticed that if I copy the source from Mozilla Firebird and save it via BBEdit it works straight up.
I have tried "Zap Gremlins" and "Convert to ASCII" in BBEdit with no luck...
HELP!
EDIT
I have also tried changing from Macintosh to DOS, UNIX and Unicode text