SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Jan 2005
    Location
    ble
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Cannot modify header infomation - headers already sent.

    Hi,

    I'm having the below problem when I vote on a poll on a site..

    Warning: Cannot modify header information - headers already sent by (output started at /header.php:77) in /poll/poll_cookie.php on line 21

    You can still vote on it, its just this error comes up and streches the table If anyone can help that would be greatful..

    If you wanted to know, its an RPG game, and theres alot of code in header.php and I hate problems with the sessions iswell before..

    Also heres line twenty one :

    Code:
            setcookie($cookie_name, "1", $endtime);
    And if you wanted, heres the poll code:

    Code:
    <?php
    $cookie_expire = 96; // hours
    
    $action = (isset($HTTP_GET_VARS['action'])) ? $HTTP_GET_VARS['action'] : '';
    $action = (isset($HTTP_POST_VARS['action'])) ? $HTTP_POST_VARS['action'] : $action;
    $poll_ident = (isset($HTTP_GET_VARS['poll_ident'])) ? $HTTP_GET_VARS['poll_ident'] : '';
    $poll_ident = (isset($HTTP_POST_VARS['poll_ident'])) ? $HTTP_POST_VARS['poll_ident'] : $poll_ident;
    
    if ($action=="vote" && (isset($HTTP_POST_VARS['option_id']) || isset($HTTP_GET_VARS['option_id']))) {
        $cookie_name = "AdvancedPoll".$poll_ident;
        if (!isset($HTTP_COOKIE_VARS[$cookie_name])) {
            $endtime = time()+3600*$cookie_expire;
            setcookie($cookie_name, "1", $endtime);
        }
    }
    ?>
    If someone was helpful, give them some 'rep'.

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    The problem is on header.php line 77 not on this code!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Zealot Krieger's Avatar
    Join Date
    Dec 2003
    Location
    Nevada - USA
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As spikeZ said - line 77.

    Also - if nothing jumps out as an obvious problem try checking for whitespace. If whitespace is encountered (spaces, characters, carriage returns) the browser will interpret this as output and send the headers.

    When I run into this it's usually an accidental carriage return at the end of an include file.
    Verwüstung rufen und des Krieges Hund' entfesseln!

    My Site
    My first php/MySQL project -->Thanks Sitepoint members

  4. #4
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    html header

    do you apply any html header to your php script.. because in my experience it can cause u that problem..

  5. #5
    3MTA3
    Join Date
    Jul 2003
    Location
    Florida
    Posts
    1,016
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could put:
    PHP Code:
    ob_start(); 
    at the very top of the page, and then put:
    PHP Code:
    ob_end_flush(); 
    at the very end of the page to buffer the output.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •