If your code looks to be ok, I have found that this is often caused by the use of Short Open tags in PHP.
The full tag is :
but the short open tag can be used as well.
However, you must allow short open tags in your PHP.INI file. Look for the SHORT_OPEN_TAG directive in your PHP.INI file and set it to "1"
I hope this helps.