Gayner Posted December 2, 2009 Share Posted December 2, 2009 Warning: Cannot modify header information - headers already sent by (output started at /home/praylife/public_html/index.php:29) in /home/praylife/public_html/index.php on line 188 Warning: Cannot modify header information - headers already sent by (output started at /home/praylife/public_html/index.php:29) in /home/praylife/public_html/index.php on line 189 LINE 189: if (isset($_GET['skin']) && $_GET['skin'] == "0") { setcookie("skinid", "default", time()+60*60*24*60, "/"); header('Location: ./?'); } LINE 29: if(!isset($_COOKIE['skinid'])) { echo '<style type="text/css" media="all">@import url(2.css);</style>'; } Ever since i moved from localhost to official server, this is happening why? Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/ Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 please read this http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969769 Share on other sites More sharing options...
Gayner Posted December 2, 2009 Author Share Posted December 2, 2009 please read this http://www.phpfreaks.com/forums/index.php/topic,37442.0.html Why does that have any relevancy when it works on localhost, but not on a server, arn't they both php? rofl Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969779 Share on other sites More sharing options...
MisterWebz Posted December 2, 2009 Share Posted December 2, 2009 I've had this problem several times too. I think it's something caused by the beginning of your php code. Did you use session_start() at the beginning of your code? Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969781 Share on other sites More sharing options...
Mchl Posted December 2, 2009 Share Posted December 2, 2009 Behold my psychic powers: You have WampServer installed on your localhost. It's configured to use output buffering with buffer size set to 4096B. On your webhost no output buffering is enabled. Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969782 Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 that as for why its happening , for why its only happening on your server your buffering must be set on localhost and not on the server please check the settings in php output_buffering Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969784 Share on other sites More sharing options...
Gayner Posted December 2, 2009 Author Share Posted December 2, 2009 Behold my psychic powers: You have WampServer installed on your localhost. It's configured to use output buffering with buffer size set to 4096B. On your webhost no output buffering is enabled. Still doesn't help me im not as Physic as u? So ur telling me to reduce my php code? lawls i just spent 4weeks on my index.php comon and rajivgonsalves i dont got access to edit .php ini on my server, it's sharedhosting ^^ Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969786 Share on other sites More sharing options...
Mchl Posted December 2, 2009 Share Posted December 2, 2009 I'm telling you to read the sticky you've got link to above. It's explained there. Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969788 Share on other sites More sharing options...
KevinM1 Posted December 2, 2009 Share Posted December 2, 2009 You should probably look up what output buffering means.... Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969789 Share on other sites More sharing options...
rajivgonsalves Posted December 2, 2009 Share Posted December 2, 2009 then the solution to your problem is use ob_start(); however not recommended Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969799 Share on other sites More sharing options...
Gayner Posted December 2, 2009 Author Share Posted December 2, 2009 then the solution to your problem is use ob_start(); however not recommended Why not recommended cause it's output buffering? Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969803 Share on other sites More sharing options...
premiso Posted December 2, 2009 Share Posted December 2, 2009 Why not recommended cause it's output buffering? Basically it can show poor coding, meaning that you are not outputting your data at the end of the script, like you should. It is considered bad practice to output data as you go along in the code, it generally should be saved and printed out at the end altogether. To fix it, you can store all output into a string instead of echoing it out then just echo out that string at the end. The output buffering is basically like a massive band-aid over the code. Quote Link to comment https://forums.phpfreaks.com/topic/183738-warning-cannot-modify-header-information-headers-already-sent-by-output-sta/#findComment-969822 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.