PHP Error Help

Discussion in 'OT Technology' started by fl0rine2, Mar 11, 2005.

  1. fl0rine2

    fl0rine2 New Member

    Joined:
    Jan 6, 2005
    Messages:
    1,824
    Likes Received:
    0
    I'm working on setting up script for a website of mine and it keeps returning this error whenever a user logs in from the login field:

    Warning: Cannot modify header information - headers already sent by (output started at /home/wrstroud/public_html/config.php:50) in /home/wrstroud/public_html/members.php on line 21

    Can anyone help me out with this...i'm not too familiar with php.
     
  2. kingtoad

    kingtoad OT Supporter

    Joined:
    Sep 2, 2003
    Messages:
    55,914
    Likes Received:
    8
    Location:
    Los Angeles
    Put <?ob_start();?> on the very top of your page, then at the very bottom, put <? ob_end_flush(); ?>
     
  3. Astro

    Astro Code Monkey

    Joined:
    Mar 18, 2000
    Messages:
    2,047
    Likes Received:
    0
    Location:
    Cleveland Ohio
    Using ob_start() should definitely wiggle around the problem. But its not usually good practice to just slap it all over PHP pages (the server takes a performance hit and has to build the entire page in memory before dumping it to the browser).

    The proper way to go about this is to troubleshoot what is being output to the browser before your header code (probably doing something with sessions or cookies). If you output text to the browser before issuing your headers, you'll get this error. Usually its just a matter of rethinking your code structure and a matter of strategically sprinkingly in some if() or switch() statements where needed.

    But yeah, as a quick fix, ob_start() should get the job done.
     
  4. SLED

    SLED build an idiot proof device and someone else will

    Joined:
    Sep 20, 2001
    Messages:
    28,118
    Likes Received:
    0
    Location:
    AZ, like a bauce!
    i typically run into this error when i'm debugging a page and forgot to take a bit of code out where i was just printing to the page i.e. using echo or something.
     

Share This Page