1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Headers Already Sent?

Discussion in 'PHP' started by Tony Brar, Feb 2, 2013.

  1. #1
    Hi guys,

    When I try to run the following code
    screenshot.png
    I get these three errors:
    Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/42/9125042/html/user.php:1) in /home/content/42/9125042/html/user.php on line 1

    Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/42/9125042/html/user.php:1) in /home/content/42/9125042/html/user.php on line1

    Warning: session_regenerate_id() [function.session-regenerate-id]: Cannot regenerate session id - headers already sent in /home/content/42/9125042/html/user.php on line 4
    Why?
    I thought if the first thing I did was start the session, without any output on the page, headers weren't sent yet.
    What might be sending the headers?

    Thanks,
    -Tony
     
    Solved! View solution.
    Tony Brar, Feb 2, 2013 IP
  2. #2
    EricBruggema, Feb 2, 2013 IP
  3. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #3
    Well, the first line was <?, and then the session stuff caused an error.
    I'll check that link in the morning... yawn.

    Thanks,
    -Tony
     
    Tony Brar, Feb 2, 2013 IP
  4. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #4
    Then BOM (unreadable start of your document) is causing the problem. Gl.
     
    EricBruggema, Feb 2, 2013 IP
  5. abraham26

    abraham26 Member

    Messages:
    73
    Likes Received:
    6
    Best Answers:
    2
    Trophy Points:
    48
    #5
    abraham26, Feb 3, 2013 IP
  6. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #6
    EricBruggema, Feb 3, 2013 IP
  7. Tony Brar

    Tony Brar Active Member

    Messages:
    220
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    75
    #7
    I told my editor (Notepad++) to convert the file to 'UTF-8 without BOM'
    options.png
    It doesn't come up with the error anymore!

    Thanks,
    -Tony
     
    Tony Brar, Feb 3, 2013 IP