jQuery.jGrowl Uncaught SyntaxError:无效或意外的令牌

I know that this question have been asked before but I still couldn't find the solution for my problem.. The thing is.. it happens at production server, but works well in development. So I'm not sure whats wrong with it. Appreciate if you could advice. Thanks in advance.

The following is my code.. and I had this "Uncaught SyntaxError: Invalid or unexpected token" error on my jQuery.jGrowl

<script src="<?php echo base_url(); ?>js/jquery.jgrowl.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>css/jquery.jgrowl.css">
<?php $message  = $_SESSION['message'];
  if($message) { ?>
    <script>
      jQuery(function(){
        jQuery.jGrowl("<?php echo $message; ?>", { header: 'Message' });
      });
    </script>
    <?php $_SESSION['message'] = '';
  }
?>

I get this error:

Uncaught SyntaxError: Invalid or unexpected token

On this line:

jQuery.jGrowl("<?php echo $message; ?>", { header: 'Message' });

I guess your $message string contains chars, which breaks the string. This could be a " or char. You could fix this by usig an escape function.

json_encode should be sufficient

jQuery.jGrowl(<?php echo json_encode($message); ?>, { header: 'Message' });

Note, that i removed the " around the string.