Jump to content

connot modify header information


heldenbrau

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/170854-connot-modify-header-information/
Share on other sites

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.

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

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.

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. 

 

 

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.