I don’t know if this is the issue, but you have to remove the exclamation point and double-dashes so it’s not a comment. As shown in your post the code is incorrect in this part:
<!--?php
You need to just write it like this:
<?php
and same for the end too:
?-->
should be
?>
I hope it helps you