Cannot modify header

Discussion in 'PHP' started by cesarcesar, Mar 6, 2008.

  1. #1
    I have a page I'm calling headers on. I'm getting the error
    So i use headers_sent() to see where the issue is. It says line 1. At line 1 I only have a <?php on the line with NO white space before it. more test.. same error. I then remove everything and only have one line of code with a header(Location:http://www.blabla.com) on line 1. Again no white space before or after PHP. Still the same error.

    Why is this happening? Why are my headers failing? Thanks much.
     
    cesarcesar, Mar 6, 2008 IP
  2. decepti0n

    decepti0n Peon

    Messages:
    519
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you sending it before an HTML? All headers (which include setcookie(), header() and most session functions) have to be sent before any HTML is output
     
    decepti0n, Mar 6, 2008 IP
  3. Altari

    Altari Peon

    Messages:
    188
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Could you post everything you have in the file?

    Also, my husband showed me this once, and sometimes it works, for whatever reason...remove the closing php tag (?>). I don't know why, but sometimes having it there in an all PHP document causes that message.
     
    Altari, Mar 6, 2008 IP
  4. cesarcesar

    cesarcesar Peon

    Messages:
    188
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Found the problem. Thanks to all those that helped.

    Basically there was some type of invisible character in the beginning of my file. I copied all of the file but the first and last character, then pasted into a new doc. Saved over the old doc and it works!

    I'm using EditPlus3 text editor in case anyone knows why this invisible char was added.
     
    cesarcesar, Mar 6, 2008 IP