How to check if drupal_get_messages() returns an empty array I am running drupal 6.22 with MySQL. I am trying to check if there is any error message set by using the following If statement, but with no luck.

if(count(drupal_get_messages('error',FALSE)) &gt; 0){
...
}


When I try this condition, I get a parse error saying...

Parse error: syntax error, unexpected T_IF 


What am I doing wrong here? And how do I check if there is any error message in the message queue?
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.