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)) > 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.

  • You were right. I missed a semicolon before the if statement. Thanks for the quick reply. – Vivek Jan 23 '12 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.