www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Server-Side Development > PHP

    PHP Discussion and technical support for using and deploying PHP based websites.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 07-28-2005, 03:12 PM
    Funny Guy's Avatar
    Funny Guy Funny Guy is offline
    FGComics.com Webmaster
     
    Join Date: Jun 2005
    Location: Pennsylvania, USA
    Posts: 34
    "Cannot modify header information"?

    On the top of my web page, I have this error message:

    Warning: Cannot modify header information - headers already sent by (output started at /home/fgcomics/public_html/tester.php:6) in /home/fgcomics/public_html/tester.php on line 25

    Code for top of page:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>FGComics.com :: TEMPLATE</title>
    <?php
    /* To add new skins, just put a new option in 
    the drop-down menu for it. Follow the format
    of previous options. */
    
    if (isset($_GET["skinpref"]))
    {
        $skinpref = $_GET["skinpref"];
    }
    elseif (isset($_COOKIE['skinpref'])) 
    {
        $skinpref = $_COOKIE['skinpref'];
    }
    else
    {
    	// Default style
        $skinpref = blue; 
    }
    // Set a cookie with the new style
    setcookie("skinpref", $skinpref, time()+432000, "/", "http://www.fgcomics.com"); 
    echo '<link rel="stylesheet" type="text/css" href="http://www.fgcomics.com/css/fgcomics_'.$skinpref.'.css">'."\n"; 
    ?>
    <script type="text/javascript">
    <!---
    function MM_jumpMenu(targ,selObj,restore)
    { 
      eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
      if (restore) selObj.selectedIndex=0;
    }
    //--->
    </script>
    <style type="text/css">
    <!--
    .style1 {color: #004182}
    -->
    </style>
    </head>
    Line 25:

    Code:
    setcookie("skinpref", $skinpref, time()+432000, "/", "http://www.fgcomics.com");
    Reply With Quote
      #2  
    Old 07-28-2005, 03:17 PM
    bokeh's Avatar
    bokeh bokeh is offline
    Keep it simple, stupid!
     
    Join Date: Jan 2005
    Location: Alicante (Spain)
    Posts: 7,705
    You cannot set a cookie after output has been sent to the client. Try putting the following right at the beginning of your script Before the html and any whitespace:
    <?php ob_start(); ?>
    Reply With Quote
      #3  
    Old 07-28-2005, 03:25 PM
    Funny Guy's Avatar
    Funny Guy Funny Guy is offline
    FGComics.com Webmaster
     
    Join Date: Jun 2005
    Location: Pennsylvania, USA
    Posts: 34
    It worked, but what was that?

    ob_start();
    Reply With Quote
      #4  
    Old 07-28-2005, 03:29 PM
    bokeh's Avatar
    bokeh bokeh is offline
    Keep it simple, stupid!
     
    Join Date: Jan 2005
    Location: Alicante (Spain)
    Posts: 7,705
    Output buffering. It stops any output being sent until after processing has been completed. This allows the output to be sent in the correct order even if it has been written in the wrong order.
    Reply With Quote
      #5  
    Old 10-15-2005, 10:31 PM
    occultbird occultbird is offline
    Registered User
     
    Join Date: Oct 2005
    Posts: 1
    Thank you

    Unbelievable! I've searched for 12 hours to find your quick and easy answer.

    THANK YOU! THANK YOU!!
    Reply With Quote
      #6  
    Old 11-14-2008, 03:46 AM
    kumaravasthi kumaravasthi is offline
    Registered User
     
    Join Date: Nov 2008
    Posts: 1
    Thumbs up You are Genius

    You saved my Time.


    It was the only post that I read for the solution of my problem and it solved the issue.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 10:22 PM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.