strange error on my site

Discussion in 'Web Design and Development' started by Cabbit, Dec 17, 2006.

  1. Cabbit macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #1
    ERROR

    Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/index.php:8) in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/forum/includes/sessions.php on line 366

    Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/index.php:8) in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/forum/includes/sessions.php on line 367

    CODE

    <div id="navBar">
    <div id="sectionLinks">
    <div> <h3>Hot Forum Topics </h3> </div>
    <?php
    $phpbb_root_path = './forum/';
    define ('IN_PHPBB', true);
    include_once ($phpbb_root_path . 'extension.inc');
    include_once ($phpbb_root_path . 'common.' . $phpEx);
    include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    init_userprefs($userdata);
    if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    {
    $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    if (!intval($CFG['posts_span_pages_offset']))
    {
    $CFG['posts_span_pages_offset'] = 0;
    }
    }
    $CFG['posts_limit'] = 6;
    $CFG['posts_span_pages'] = true;
    $latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>


    <?php for ($i = 0; $i < count($latest); $i++) { ?>

    <a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $latest[$i]['topic_id']); ?>"><?php echo $latest[$i]['topic_title']; ?></a>
    <?php } ?>
    </div>

    Question

    were is this error coming form and why dosnt it show up on the site all the time.
     
  2. angelneo macrumors 68000

    Joined:
    Jun 13, 2004
    Location:
    afk
    #2
    The warning was caused by php tries to edit the header of the page but html code has been sent out. Try to put the code in this order:

    CODE
    <?php
    $phpbb_root_path = './forum/';
    define ('IN_PHPBB', true);
    include_once ($phpbb_root_path . 'extension.inc');
    include_once ($phpbb_root_path . 'common.' . $phpEx);
    include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    init_userprefs($userdata);
    if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    {
    $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    if (!intval($CFG['posts_span_pages_offset']))
    {
    $CFG['posts_span_pages_offset'] = 0;
    }
    }
    $CFG['posts_limit'] = 6;
    $CFG['posts_span_pages'] = true;
    $latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>


    <div id="navBar">
    <div id="sectionLinks">
    <div> <h3>Hot Forum Topics </h3> </div>


    <?php for ($i = 0; $i < count($latest); $i++) { ?>

    <a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $latest[$i]['topic_id']); ?>"><?php echo $latest[$i]['topic_title']; ?></a>
    <?php } ?>
    </div>

    COMMENT
    Do not leave any white spaces or line break before your first line of php code.
     
  3. rogersmj macrumors 68020

    rogersmj

    Joined:
    Sep 10, 2006
    Location:
    Indianapolis, IN
    #3
    It tells you where the error is coming from: /forum/includes/sessions.php. That page is trying to modify header information, but it can't because another page (in this case, /index.php) has already output data to the browser. Most of the time, modifying headers is used to redirect a page. I'm guessing that since this doesn't happen all the time, your sessions.php is trying to redirect you to the login page once the session times out.

    This is a perfect example of why mixing PHP (logic) and HTML (display) sucks. Templating systems are much better. But, barring that, you can probably fix this by moving all of your PHP logic to the top of your files, especially the include lines. Don't start outputting HTML until you have everything worked out as far as what you want to display.

    And in the future, it's a lot easier to read code if you encapsulate it in forum "code" tags.
     
  4. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #4
    i tryed to do what both of you guys suggested but it just came up errors. \

    here is the full code. if you can fix the bit that is broke i would be most happy.

    CODE

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">


    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Jennifer's Playgroup</title>
    <link rel="stylesheet" href="3col_rightNav.css" type="text/css" />
    <style type="text/css">
    <!--
    .style1 {font-size: 120%}
    .style2 {font-size: 115%}
    body {
    background-image: url(site_images/lines.gif);
    }
    -->

    </style></head>
    <body>
    <div id="container">

    <div id="masthead">
    <h1 id="siteName">Jennifer's Playgroup </h1>
    <div id="globalNav"> <a href="/index.php">Home</a> | <a href="/forum"></a><a href="/shop/catalog">Store</a> | <a href="/forum">Forum</a> | <a href="/news.php">News & Events </a>| <a href="/pictures.php">Pictures</a>| <a href="/videos.php">Videos </a> | <a href="/reviews.php">Reviews</a> | <a href="/links.php">Links</a> </div>
    <div> <h2 class="style1" id="pageName">Welcome To My Playgroup</h2>
    </div>
    </div>
    <div id="headlines">
    <h3 class="style2">Headlines</h3>
    <p>Site Opening <a href="news_storys/news_story1.php">full story...</a></p>
    <p> Headline <a href="#">full story...</a> </p>
    <p> Headline <a href="#">full story...</a> </p>
    <p> Headline <a href="#">full story...</a> </p>
    <p> Headline <a href="#">full story...</a> </p>
    <div id="advert"> <img src="/site_images/playgroup.jpg" alt="" width="200" height="176" /> Our <a href="/forum">Forum</a> is the place to be for bAby's, mummies and even little sissy's and bigger kids </div>
    </div>
    <!-- end masthead -->
    <div id="content">
    <div class="feature"><img src="site_images/logo.jpg" alt="" width="207" height="242" />
    <h3>Welcome</h3>
    <p> Welcome to my playgroup, allis mine yip yip yip. But you are all welcome too.</p>
    <p>This side deals with infantilism. Our <a href="/forum">forum</a> is were it is at for all you bAby's and carers you can chat with other people like yourself.</p>
    <p> Take a trip our online store for a wide selection of bAby products includeing nappys, cloths and fetish products, we also have some very exciteing new products in the works.(opening soon) </p>
    <p>Visit our <a href="/pictures.php">picture</a> archive's wear you will find the best form the web that have been colected by my self painstackenly for many years</p>
    <p>Also visit the <a href="/news.php"> News & Events</a> section for all the latest Adult Baby news were you will find news of any party's going on in your area. </p>
    </div>
    <div class="story">
    <h3>Latest Update 16-12-06 </h3>
    <p> So what's new, well a lot you don't really see really. First of the homepage is in the middle of being redeveloped into PHP so that i can create dynamic links the the forum and other parts of the site, you will see this feature is working now but there are a few bugs to iron out. Also im working on a nice colour scheme that will look both a little more fun that the boring blue, im keeping the body text black so you can read it but the font has changed. There are a lot more changes in the works and you will notice these from day to day. Mostly these will be cosmetic for now, once i am happy with the site look and that everything is all working fine i will finish the rest of the site pages. </p>
    </div>
    <div class="story">
    <h3>Update 04-12-06 </h3>
    <p> Ok well this is the first in a long line of updates, so your asking "what's new" well the answer is everything simple answer and you will notice not everything is working yet, and there is a pretty good reason for that, rome wasn't built in a day and nor will my site be. I can tell you the forum will be up and running by the end of the week and with any luck we will have the store up and running soon as well, but for now don't try buy anything cos there is nothing to buy. Some of the links down work and the site is generally just not ready yet. </p>
    </div>
    <div class="story">
    <h3>A Little About this site and who it is for </h3>
    <p>This site deals with infantilism and other age play fetishes and life styles. This includes teen baby's, adult baby's, diaper lovers, age players and there respective careers. This has absolutely nothing to do with children nor pedophilia were just not interested in children, like all societies we have had a couple bad eggs that make us all look bad, if you are not a infantilism or have no interest in such things then you shouldn't be here. If your here looking for pictures of kids look else were no one here is interested in such things.</p>
    <p><a href="http://en.wikipedia.org/wiki/Paraphilic_infantilism">infantilism Wikipedia </a>Paraphilic infantilism is the desire to wear diapers and be treated as a helpless infant. One who engages in infantilism play is known as an adult baby (AB) or teen baby (TB), depending on age. About one in three adult babies is also a diaper lover so they are collectively known as AB/DLs. The majority of infantilisms are heterosexual males.</p>
    <p>Infantilism and diaper fetishes differ in self-image and the focus of attention. However, they can coexist in individuals and have some similarities in practice. Neither include a sexual preference for children. There is no singular, archetypical infantilism, but a range. Some fantasize about being free of guilt, responsibility, or control while others might not. Some act indistinguishably from a baby at times, while others practice in a way that would be unnoticed by passers by on the street. The desires and tastes of infantilisms vary around common themes of diapers and babyhood</p>
    </div>
    </div>
    <!-- end content -->
    <div id="navBar">
    <div id="sectionLinks">
    <div> <h3>Hot Forum Topics </h3> </div>
    <?php
    $phpbb_root_path = './forum/';
    define ('IN_PHPBB', true);
    include_once ($phpbb_root_path . 'extension.inc');
    include_once ($phpbb_root_path . 'common.' . $phpEx);
    include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    $userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    init_userprefs($userdata);
    if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    {
    $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    if (!intval($CFG['posts_span_pages_offset']))
    {
    $CFG['posts_span_pages_offset'] = 0;
    }
    }
    $CFG['posts_limit'] = 6;
    $CFG['posts_span_pages'] = true;
    $latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>
    <?php for ($i = 0; $i < count($latest); $i++) { ?>
    <a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $latest[$i]['topic_id']); ?>"><?php echo $latest[$i]['topic_title']; ?></a>
    <?php } ?>
    </div>
    <div class="relatedLinks">
    <h3>Soon to the Store </h3>
    <ul>
    <li><a href="#">Coming Soon</a></li>
    <li><a href="#">Coming Soon</a></li>
    <li><a href="#">Coming Soon</a></li>
    <li><a href="#">Coming Soon</a></li>
    <li><a href="#">Coming Soon</a></li>
    <li><a href="#">Coming Soon</a></li>
    </ul>
    </div>
    <div class="relatedLinks">
    <h3>Top External Links </h3>
    <ul>
    <li><a href="http://abdl-fetish-shop.baby-doll.com/index.php?main_page=index&zenid=09b573a74c17d4923a1c713a6761ef5f">Baby-Doll DVD's'</a></li>
    <li><a href="http://cosyndry.com/">Cosyndry bAby Shop</a></li>
    <li><a href="http://www.hbenterprises.co.uk/Catalogue_GW.html">Precious Babywear Shop</a></li>
    <li><a href="http://aby.com/apm/home.php">bAby Dating Service</a></li>
    <li><a href="http://dailydiapers.com/">Daily Diapers Newspaper</a></li>
    <li><a href="http://www.happynappy.co.uk/html/pushchair.html">Happy Nappy Nursery</a></li>
    </ul>
    </div>
    </div>
    <div id="siteInfo"><a href="/about.php">About Us</a> |<a href="/map.php"> Site Map</a>|<a href="/contact.php"> Contact Us</a> | ©2006 Jennifer's Playgroup </div>
    <br />
    </div>
    </body>
    </html>
     
  5. rogersmj macrumors 68020

    rogersmj

    Joined:
    Sep 10, 2006
    Location:
    Indianapolis, IN
    #5
    Jennifer--

    There's no way we can fix and verify it because we don't have access to all those files on your server that this code is referencing.

    I guarantee you that if you put all of your PHP logic up top, before the DOCTYPE and anything else, that you will be well on your way to solving this problem. Put all your logic up top, set variables you may need for output later, and then echo those variables down in the HTML portion. The code you just pasted here does not follow that convention at all. Set it up like that, and if you still get errors then tell us what those are and we'll go from there. We cannot help you any more unless you separate your PHP and HTML.

    And once again, don't put code in a post without encapsulating it with "code" forum tags.
     
  6. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #6
    Code:
    	    <?php
    	$phpbb_root_path = './forum/';
    	define ('IN_PHPBB', true);
    	include_once ($phpbb_root_path . 'extension.inc');
    	include_once ($phpbb_root_path . 'common.' . $phpEx);
    	include_once ($phpbb_root_path . 'includes/bbcode.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/common.' . $phpEx);
    	include_once ($phpbb_root_path . 'mods/phpbb_fetch_all/posts.' . $phpEx);
    	$userdata = session_pagestart($user_ip, PAGE_INDEX, $session_length);
    	init_userprefs($userdata);
    	if (isset($HTTP_GET_VARS['start']) or isset($HTTP_POST_VARS['start']))
    	{
    	        $CFG['posts_span_pages_offset'] = isset($HTTP_GET_VARS['start'])
    	        ? $HTTP_GET_VARS['start'] : $HTTP_POST_VARS['start'];
    	        if (!intval($CFG['posts_span_pages_offset']))
    	        {
    	                $CFG['posts_span_pages_offset'] = 0;
    	        }
    	}
    	$CFG['posts_limit'] = 6;
    	$CFG['posts_span_pages'] = true;
    	$latest = phpbb_fetch_posts(null, POSTS_FETCH_LAST); ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <title>Jennifer's Playgroup</title>
    <link rel="stylesheet" href="3col_rightNav.css" type="text/css" />
    <style type="text/css">
    <!--
    .style1 {font-size: 120%}
    .style2 {font-size: 115%}
    body {
    	background-image: url(site_images/lines.gif);
    }
    -->
    
    </style></head>
    <body>
    <div id="container">
    
    <div id="masthead">
      <h1 id="siteName">Jennifer's Playgroup </h1>
      <div id="globalNav"> <a href="/index.php">Home</a> | <a href="/forum"></a><a href="/shop/catalog">Store</a> | <a href="/forum">Forum</a> | <a href="/news.php">News & Events </a>| <a href="/pictures.php">Pictures</a>| <a href="/videos.php">Videos </a> | <a href="/reviews.php">Reviews</a> | <a href="/links.php">Links</a> </div>
      <div> <h2 class="style1" id="pageName">Welcome To My Playgroup</h2> 
      </div>
    </div>
    <div id="headlines">
      <h3 class="style2">Headlines</h3>
      <p>Site Opening <a href="news_storys/news_story1.php">full story...</a></p>
      <p> Headline <a href="#">full story...</a> </p>
      <p> Headline <a href="#">full story...</a> </p>
      <p> Headline <a href="#">full story...</a> </p>
      <p> Headline <a href="#">full story...</a> </p>
      <div id="advert"> <img src="/site_images/playgroup.jpg" alt="" width="200" height="176" /> Our <a href="/forum">Forum</a> is the place to be for bAby's, mummies and even little sissy's and bigger kids </div>
    </div>
    <!-- end masthead -->
    <div id="content">
      <div class="feature"><img src="site_images/logo.jpg" alt="" width="207" height="242" />
        <h3>Welcome</h3>
        <p> Welcome to my playgroup, allis  mine yip yip yip. But you are all welcome too.</p>
        <p>This side deals with infantilism. Our <a href="/forum">forum</a> is were it is at for all you bAby's and carers you can chat with other people like yourself.</p>
        <p> Take a trip our online store for a wide selection of bAby products includeing nappys, cloths and fetish products, we also have some very exciteing new products in the works.(opening soon) </p>
        <p>Visit our <a href="/pictures.php">picture</a> archive's wear you will find the best form the web that have been colected by my self painstackenly for many years</p>
        <p>Also visit  the <a href="/news.php"> News & Events</a> section for all the latest Adult Baby news were you will find news of any party's going on in your area. </p>
      </div>
      <div class="story">
        <h3>Latest Update 16-12-06 </h3>
        <p> So what's new, well a lot you don't really see really. First of the homepage is in the middle of being redeveloped into PHP so that i can create dynamic links the the forum and other parts of the site, you will see this feature is working now but there are a few bugs to iron out. Also im working on a nice colour scheme that will look both a little more fun that the boring blue, im keeping the body text black so you can read it but the font has changed. There are a lot more changes in the works and you will notice these from day to day. Mostly these will be cosmetic for now, once i am happy with the site look and that everything is all working fine i will finish the rest of the site pages. </p>
      </div>
      <div class="story">
        <h3>Update 04-12-06 </h3>
        <p> Ok well this is the first in a long line of updates, so your asking "what's new" well the answer is everything simple answer and you will notice not everything is working yet, and there is a pretty good reason for that, rome wasn't built in a day and nor will my site be. I can tell you the forum will be up and running by the end of the week and with any luck we will have the store up and running soon as well, but for now don't try buy anything cos there is nothing to buy. Some of the links down work and the site is generally just not ready yet. </p>
      </div>
      <div class="story">
        <h3>A Little About this site and who it is for </h3>
        <p>This site deals with infantilism and other age play fetishes and life styles. This includes teen baby's, adult baby's, diaper lovers, age players and there respective careers. This has absolutely nothing to do with children nor pedophilia were just not interested in children, like all societies we have had a couple bad eggs that make us all look bad, if you are not a infantilism or have no interest in such things then you shouldn't be here. If your here looking for pictures of kids look else were no one here is interested in such things.</p>
        <p><a href="http://en.wikipedia.org/wiki/Paraphilic_infantilism">infantilism Wikipedia  </a>Paraphilic infantilism is the desire to wear diapers and be treated as a helpless infant.  One who engages in infantilism play is known as an adult baby (AB) or teen baby (TB), depending on age. About one in three adult babies is also a diaper lover  so they are collectively known as AB/DLs. The majority of infantilisms are heterosexual males.</p>
        <p>Infantilism and diaper fetishes differ in self-image and the focus of attention. However, they can coexist in individuals and have some similarities in practice. Neither include a sexual preference for children. There is no singular, archetypical infantilism, but a range. Some fantasize about being free of guilt, responsibility, or control while others might not. Some act indistinguishably from a baby at times, while others practice in a way that would be unnoticed by passers by on the street. The desires and tastes of infantilisms vary around common themes of diapers and babyhood</p>
      </div>
    </div>
    <!-- end content -->
    <div id="navBar">
      <div id="sectionLinks">
        <div> <h3>Hot Forum Topics </h3> </div>
    <?php for ($i = 0; $i < count($latest); $i++) { ?>
    <a href="<?php echo append_sid($phpbb_root_path . 'viewtopic.php?t=' . $latest[$i]['topic_id']); ?>"><?php echo $latest[$i]['topic_title']; ?></a>
    <?php } ?>
      </div>
      <div class="relatedLinks">
        <h3>Soon to the Store </h3>
        <ul>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
          <li><a href="#">Coming Soon</a></li>
        </ul>
      </div>
      <div class="relatedLinks">
        <h3>Top External Links </h3>
        <ul>
          <li><a href="http://abdl-fetish-shop.baby-doll.com/index.php?main_page=index&zenid=09b573a74c17d4923a1c713a6761ef5f">Baby-Doll DVD's'</a></li>
          <li><a href="http://cosyndry.com/">Cosyndry bAby Shop</a></li>
          <li><a href="http://www.hbenterprises.co.uk/Catalogue_GW.html">Precious Babywear Shop</a></li>
          <li><a href="http://aby.com/apm/home.php">bAby Dating Service</a></li>
          <li><a href="http://dailydiapers.com/">Daily Diapers Newspaper</a></li>
          <li><a href="http://www.happynappy.co.uk/html/pushchair.html">Happy Nappy Nursery</a></li>
    	<li><a href="http://www.babyjunior.co.uk/html/home.html">Baby Junior</a></li>
        </ul>
      </div>
    </div>
    <div id="siteInfo"><a href="/about.php">About Us</a> |<a href="/map.php"> Site Map</a>|<a href="/contact.php"> Contact Us</a> | ©2006 Jennifer's Playgroup </div>
    <br />
    </div>
    </body>
    </html>
    ok what it dose now is no longer displays the error but it doubles the page. my site
    same errors but now at the top of the page
    <code>
    Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/index.php:1) in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/forum/includes/sessions.php on line 366

    Warning: Cannot modify header information - headers already sent by (output started at /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/index.php:1) in /home/fhlinux178/j/jennifersplaygroup.co.uk/user/htdocs/forum/includes/sessions.php on line 367</code>
     
  7. rogersmj macrumors 68020

    rogersmj

    Joined:
    Sep 10, 2006
    Location:
    Indianapolis, IN
    #7
    I looked at the root of your site, I don't see any code errors at all. Is that the page you're trying to implement this on? Or is there another one?

    Also I strongly recommend running your posts through a spell checker.
     
  8. Cabbit thread starter macrumors 68020

    Cabbit

    Joined:
    Jan 30, 2006
    Location:
    Scotland
    #8
    sorry about the spelling i do have the apple spell check switched on but it dosn't pick up everything. i think i fixed the error, will i experience any errors if all my pages have this same code in it, i intend to just copy the main page and edit it to suite.
     
  9. Grover macrumors member

    Joined:
    May 14, 2004
    #9
    I've noticed this happen if the code file's encoding is not to the PHP engine's liking. For instance, if you have a UNICODE encoding with a byte order marker. Some editors will display this as a what looks like garbage characters at the start of the file. If you see this happen again, and the code looks right otherwise, it might be worth converting the file to plain ASCII or to a UNICODE encoding with no BOM to see if that makes a difference.

    My memory is that this is not consistent from platform to platform so you could develop on OSX and have the Linux engine choke on the file (or the other way around, I don't remember which it was when I noticed it.)

    Also, as angelneo suggested, try removing any whitespace before the opening <?php and after the closing ?>. Sometimes whitespace that's not between the PHP tags can cause problems.
     
  10. stndn macrumors member

    Joined:
    Oct 22, 2006
    Location:
    earth
    #10
    I just opened your website and didn't see any errors like you had.

    Without the code from the offending file/line (sessions.php line 366 and 367), it's somewhat hard to figure out what's causing the error.

    However, here are a few hints that might help you:

    1.
    Most of the time, the error you have means that the code expects to be the first to be executed when user loads the page. In other words, there must not be any text or output sent to the browser before this code gets executed.

    My memory is not serving me well at this moment, but a few examples of such commands in php are header() function, and session_start().

    2.
    For such functions, you have to make sure that they get called before any text gets sent to the browser, this means: no print() statements, no white spaces, no letters/alphabets, etc. must be present before the call to session_start()


    There are a few ways you can do to avoid this problem with 'header already sent':

    1.
    Put the offending code before anything else. If this means calling the function before doing anything at all, then by all means do that.

    2.
    Do not leave any white spaces outside of the starting <?php tag and ending ?> tag. This includes an innocent space, tab, or newline character. This is somewhat hard to do due to the spaces are often 'hidden'. However, if you highlight your code, you might be able to see the white spaces being highlighted.

    Otherwise, check the program you used to write the code and see if they have options to trim excess white spaces.

    3.
    Make use of ob_start() and ob_end_flush() to 'hold off' the output until you've done everything else before outputting them to the user.


    Not sure if that helps or actually confused you more. But if it helps, then it's good -)


    -stndn.
     
  11. 4np macrumors 6502a

    4np

    Joined:
    Feb 23, 2005
    Location:
    The Netherlands
    #11
    Solution 1: add the following lines to the top of index.php

    Code:
    <?php
    if (!session_id()) {
      session_start();
    }
    ?>
    Solution 2: add a .htaccess file to your document root with the following line

    php_value session.auto_start 1

    Solution 3: edit your apache virtual host configuration to contain the following line:

    php_value session.auto_start 1

    As mentioned before you are trying to send out HTTP headers (in this case session cookies) after you have already sent out header and content (the html above your php code). Anytime you want to send out http headers (like header locations for example) you do that before you output anything else to the client (eg: Web Browser).

    See php's header manual for more information...

    Good luck...
     

Share This Page