Help With PHP Error, ASAP

Discussion in 'PHP' started by BrettOwnz, Mar 8, 2009.

  1. #1
    Hey there everyone. I am getting this error:

    Warning: Cannot modify header information - headers already sent by (output started at /usr/www/users/rizonct/terms.php:1) in /usr/www/users/rizonct/includes/config.inc.php on line 8

    on my page, terms.php. I will provide the snippets of code i believe to be causing the problem, please tell me how to fix this asap if you can!

    Top of terms.php:
    <?php
    include('includes/config.inc.php');
    require_once('includes/online.inc.php');
    require_once('includes/banned.inc.php');
    ?>
    <?php 
      include ('header.php'); 
      include ('includes/index.inc.php');		
      include_once('header.php');
      if (isset($_COOKIE["usNick"]) && isset($_COOKIE["usPass"])) {
          $user = $_COOKIE["usNick"];
      } else {
      $user = 'Guest';
    }
    ?>
    PHP:
    Config.inc.php:
    <?php
    require_once ('database/database.inc.php');
    $myDb = new Db;
    include ('siteconfig.inc.php');
    require_once ('controls.inc.php');
    if(isset($_COOKIE["usReferrer"])){
    }else{
    setcookie("usReferrer",limpiar($_GET["ref"]),time()+7776000);
    }
    ?>
    PHP:
    Thank you, all your help is greatly appreciated!
     
    BrettOwnz, Mar 8, 2009 IP
  2. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #2
    Replace the top part of terms.php with:

    
    <?php
    ob_start();
    include('includes/config.inc.php');
    require_once('includes/online.inc.php');
    require_once('includes/banned.inc.php');
    ?>
    
    PHP:
     
    ads2help, Mar 8, 2009 IP
  3. yoes_san

    yoes_san Peon

    Messages:
    443
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can not modify header via header() after you've wrote a content to page using echo() or print() command.

    this means you can't put header() into the bottom of the page also.
     
    yoes_san, Mar 9, 2009 IP
  4. BrettOwnz

    BrettOwnz Member

    Messages:
    286
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #4
    ads2help, that didn't seem to work.. yoes san, i dont have any headers modified at the bottom, this page had always been fine until i changed this:

    <table id="ptable" border="0" cellspacing="5" cellpadding="5" 
    
    width="100%">
    		        <tr>
    			        <td width="48" valign="top"><img 
    
    src="images/icons/terms05.png" border="0"></a></td>
    			        <td valign="top" align="left">
    			        You must have a valid e-mail address 
    
    and valid AlertPay address to register
    					with our program. In order to 
    
    recieve payments,you must first verify your 
                                            alertpay address by paying a 
    
    one-time fee of $1.00 to RizonClickz. This is to prevent fraudsters and 
    
                                            cheaters from recieving our 
    
    money. If you fail to verify your account, you may not recieve any      
    
                                       further payments. 
    			        </td>
    		        </tr>
    	</table>
    PHP:
    all i did was change the text, then i got this error now.. i hope that can help someone help me.. Thanks for the suggestions.
     
    BrettOwnz, Mar 9, 2009 IP
  5. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #5
    If you are saving your web-pages in utf-8(UNICODE) you should take care about BOM-please google about "saving utf8 pages without bom".
    BOM causes output start, so next call to session_start()/header() results in warning.
    Regards
     
    koko5, Mar 9, 2009 IP
  6. BrettOwnz

    BrettOwnz Member

    Messages:
    286
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #6
    Hmm i just cant seem to get this to work.. what the heck is going on here!! All i changed was the text, and saved it as i normally do..
     
    BrettOwnz, Mar 9, 2009 IP
  7. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #7
    Just put this code at the most top of the file.

    For example:
    If your index.php includes header.php first, put it at the top of header.php, not index.php

    Are you sure you pasted that on the most top of file?
     
    ads2help, Mar 9, 2009 IP
  8. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #8
    You can suppress warnings by entering:
    <?php error_reporting(0);?>
    Code (markup):
    at topmost of your file instead of ob_start()->this will hide warning but is not a complete and clean solution: it's best to zip your file and post it here and let us check it.
    Regards
     
    koko5, Mar 10, 2009 IP
  9. pipes

    pipes Prominent Member

    Messages:
    12,766
    Likes Received:
    958
    Best Answers:
    0
    Trophy Points:
    360
    #9
    I discovered that too in the past when i was having trouble with a wordpress theme that i was creating, i resaved all files as UTF-8 without BOM and it solved the issue i was having.
     
    pipes, May 2, 2009 IP