I have a file that I have bootstrapped and I am trying to print messages but I can't get it to work. Here is the code does anything look wrong (mysite was changed)?

define('DRUPAL_ROOT', '/home/mysite/public_html');
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';

 <div class="description">             
  <?php global $user;

     print "Welcome " . $user->name;
     drupal_set_message(t("Don't panic!"), 'warning');
     print $messages;

1 Answer 1


To get the list of the messages set with drupal_set_message(), you should call drupal_get_messages().

Drupal doesn't use any global $messages to store those messages. They are stored in $_SESSION['messages'], but you should really use drupal_get_messages().

drupal_get_messages() returns an array; this means you cannot simply use the following code.

$messages = drupal_get_messages();
print $messages;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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