waverider303 Posted December 10, 2009 Share Posted December 10, 2009 I get this warning when I am trying to refresh the page to a different one: Warning: Cannot modify header information - headers already sent by (output started at /home/ada/public_html/v2/ada_login/main.php:9) in /home/ada/public_html/v2/ada_login/main.php on line 36 Here is the code: <?php if($session->logged_in){ header("Refresh: 3 url=welcome.php?uid=$session->userid"); echo '<h3>Creating workspace</h3>'; echo '<img src="images/loader.gif" />'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/ Share on other sites More sharing options...
rajivgonsalves Posted December 10, 2009 Share Posted December 10, 2009 read this topic it explains why http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974452 Share on other sites More sharing options...
waverider303 Posted December 10, 2009 Author Share Posted December 10, 2009 The weird thing is that this works on another site of mine. It only fails on another site I am trying to incorporate this script into. Is related to a specific version of PHP? Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974456 Share on other sites More sharing options...
rajivgonsalves Posted December 10, 2009 Share Posted December 10, 2009 why it worked on one site and not another the output buffering must be on on the site it worked Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974458 Share on other sites More sharing options...
waverider303 Posted December 10, 2009 Author Share Posted December 10, 2009 Is this something that should be on or off? Is there any effect when the buffer output is on? Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974461 Share on other sites More sharing options...
rajivgonsalves Posted December 10, 2009 Share Posted December 10, 2009 I am not sure but I think I read somewhere it increases performance of your page. maybe someone else in the forum could shed some light on this Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974463 Share on other sites More sharing options...
premiso Posted December 10, 2009 Share Posted December 10, 2009 It is generally better to code for output buffer off, especially if you plan on selling or giving the script away. But it also depends on what you are doing, for instance, if you plan on gzipping your pages up, it would be better to have output buffer on so you can serve that out easier. But for most scripts you should have it off and do proper coding where you store output in a variable and echo it out at the end of the script, so you do not mix processing with outputting, to avoid errors such as this no matter the circumstance. That and output buffering is considered a "bandaid" for solving header errors. Quote Link to comment https://forums.phpfreaks.com/topic/184585-header-warning/#findComment-974487 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.