heldenbrau Posted August 18, 2009 Share Posted August 18, 2009 I have created my website on my windows computer at home and I have moved it over to the web host which is linux. It says apache version 2.2 unix too. Now that I have moved it over, I am getting a load of cannot modify header warnings. I have read on some forums that the error is to do with the character types or something. So what do I need to do? Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/ Share on other sites More sharing options...
mikesta707 Posted August 18, 2009 Share Posted August 18, 2009 read the post stickyed at the top Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901077 Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 read the post stickyed at the top Yes, please do. The issue is most likely output to the browser, this includes whitespace, before your header call. This sticky (http://www.phpfreaks.com/forums/index.php/topic,37442.0.html) should explain everything. Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901079 Share on other sites More sharing options...
heldenbrau Posted August 18, 2009 Author Share Posted August 18, 2009 I have read about the whitespace and deleted it, but still got the error. After reading the post at the top I think my problem is lots of lines like this if (empty($_POST['verify'])) { die(header('Location:createid.php?verinone=f')); }else So do I have to put this right at the top $verinone = header('Location:createid.php?verinone=f') and then this later on? if (empty($_POST['verify'])) { die($verinone); }else Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901129 Share on other sites More sharing options...
.josh Posted August 18, 2009 Share Posted August 18, 2009 Should be like this... if (empty($_POST['verify'])) { header('Location:createid.php?verinone=f'); exit(); }else Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901135 Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 Firstly, this line should be: if (empty($_POST['verify'])) { header('Location:createid.php?verinone=f'); die(); }else Second, it's not just whitespace, it's any output to the browser. So make sure you're not echoing or displaying any HTML whatsoever before any header calls. Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901138 Share on other sites More sharing options...
heldenbrau Posted August 18, 2009 Author Share Posted August 18, 2009 It worked ok with the die before the header command. Why does the die need to come after it? I have got it working now, there was a useless echo in there near the start, now I have removed it I get no more header errors yay. Thanks for helping me understand this better. Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901167 Share on other sites More sharing options...
mikesta707 Posted August 18, 2009 Share Posted August 18, 2009 die will exit the script before the header is executed Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901172 Share on other sites More sharing options...
Maq Posted August 18, 2009 Share Posted August 18, 2009 The purpose of die after the header call is to ensure that no code afterwards will be executed. Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901182 Share on other sites More sharing options...
PFMaBiSmAd Posted August 18, 2009 Share Posted August 18, 2009 If you post the actual error message you are getting that states where the output is occurring that is preventing the header() from working, someone can actually help you with what is causing the problem. Since die(header('Location:createid.php?verinone=f')); would evaluate the supplied parameter when the die() statement is executed, that line of code is valid and functions as expected (tested.) Quote Link to comment https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/#findComment-901245 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.