1) That code needs to be just before the doc type tag. If it is not just before the doctype tag on those pages, it needs to get moved.
2) The error is caused by a blank space at the end of line 4. on line 4, you have:
"?> "
that blank space after the closing php tag is causing the error.