Place your code one in each line, provide spaces wherever necessary. There seem to be other places also where <?php and the next character is not provided a space like <?php} should be <?php }
So check your code thoroughly for required spaces, split your code into multiple lines and try again.