Warning: Cannot modify header information – headers already sent by (output started at /home/myaccount/public_html/globals.php:42) in /home/myaccount/public_html/includes/mambo.php on line 302

When you start coding your PHP in your early days most of the coders would have come a cross above warning. Experience PHP coders know how to come out of this warning.

What does give you this error warning? When you develop your PHP, XHTML, CSS locally you won’t encounter this problem. It works well, but problems occur at the moment you start hosting your web application. You might have got it even when you do redirects using the below statement.

header(“Location: login.php”);

When you use the above statement you may not always get the waring message. It comes if you have a PHP script on the top of the page. Due to various reasons PHP coders need to include scripts on the top of the page. In my case I had to start the session to read authentication information so I included the below statement.


It was working very well with my local IIS server. Moment I hosted my pages things started to fall apart. So I started digging into google. The common solution which I found was,

The “headers already sent” error is usually caused by having white space before or after the opening and closing PHP tags ().

try placing this at the top of your page:
<? ob_start(); ?>

then at the bottom of the page place this line of code:

<? ob_flush(); ?>

But none of the above fixes was able to solve my issue. After doing all of these, if you still encounter this problem you must open you php page on your editor check with what format you are saving it. If you are saving it using UTF-8 better change it to ANSI and host it. All above errors will dissapear.

For the redirects you may need to alter your code a bit, like below,

print “”;