How to check if drupal_get_messages() returns an empty array
What you get is a syntax error not a parse error, meaning that the code never executed, but PHP couldn't parse it. My hunch is that the problem is in the code before the if statement. One way of getting this error would be to do:

$var = 'foo' // Missing ;
if (TRUE) {
  $var = 'bar';
}


This would result in the error message you got.

A lot of things could be wrong, but when it is a syntax error, the gist of it, is that you made code PHP couldn't understand.