I keep getting this error:
Warning: Cannot modify header information - headers already sent by (output started at /home/round/public_html/project/checkout.php:318) in /home/round/public_html/project/checkout.php on line 929

This is where it is saying it is causing the error:

echo("<html>
<head>
<title>XYZ Checkout</title>
</head>
<body>");
include('header.php');
    display_checkout_cart($_SESSION['cart'], false, 0);

echo("
<br><br><br>
<table>
	<tr>
	<td width='25'></td>

Do you see anything wrong here?

This used to work fine. I haven't touched or changed anything and now I keep getting this error. However, we did move to a new server. Would it have something to do with the version of PHP installed on the server? It is version 4.3.4

Thanks

    Can you post the contents of header.php? i would think it would be something wrong in there

    There doesnt seem to be anything wrong with the code you've already posted.

      Basically, you cannot output anything (e.g. echo) before the last [man]header/man.

      This also applies if you're using [man]setcookie/man

        header.php looks like this:

        <?
        echo"
        <body leftmargin='0' topmargin='0'>
        <p><img src='images/header.gif' width='650' height='150'></p>
        </body>";
        ?>
        

        Like I said, I don't get it because the entire thing worked before. I never got any header errors or anything. It is a shopping cart and everything worked from login to checkout. But not now.

        Thanks

          .... perhaps you had output_buffering enabled on your old host.

          look for "output_buffering" in your php.ini and set it to 4096 or whatever you like

            Well the output_buffering in my php.ini file was turned off. I have turned it on and still get the same error. How do I set it to 4096 like you said?

            Or should just turning it on work?

            Thanks

              I am also getting this error now on a page called update.php which I had never gotten before.

              Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/round/public_html/project/header.php:5) in /home/round/public_html/project/update.php on line 6

              I assume it has got to be something within my settings for php. The entire shopping cart from beginning to end worked flawlessly before.

              Thanks

                Well, another possibility is that some code broke during the transfer, and the error handling was designed to output the problem, which of course made the header()s unhappy.

                The "Cannot send session cookie" is the same problem as with header().

                You just have to apply standard debugging techniques and discover the error yourself.

                  okay, well I can't seem to figure it out. I basically reuploaded all of the files that make up the shopping cart and replaced them on the server. If there was any code break, that should have taken care of it as I have not modified my local files at all. These all used to work without any errors before.

                  I don't believe it is any break in the code.

                  Any other suggestions?

                  Thanks

                    Are you sure you haven't changed anything? A "headers already sent" error is typically a sign of fundamental problems with program design. What is line 318 of checkout.php (or whatever the line that is being reported is now)? Is this the first or only error message displayed?

                      Yes, I am sure I have not changed a thing. It used to work fine on our old server. We moved to a new server and this started happening. I then took my unmodified local files and replaced the ones on the server. Didn't work.

                      The code is this where I am getting the error:

                      if($_POST['useContact']=="true"){
                      	$_SESSION['bfirstName'] = $result['firstName'];
                      	$_SESSION['blastName'] = $result['lastName'];
                      	$_SESSION['baddress'] = $result['address'];
                      	$_SESSION['bapt'] = $result['apt'];
                      	$_SESSION['bcity'] = $result['city'];
                      	$_SESSION['bstate'] = $result['state'];
                      	$_SESSION['bzip'] = $result['zip'];
                      	$_SESSION['bcountry'] = $result['country'];
                      }else{
                      	$_SESSION['bfirstName'] = $_POST['bfirstName'];
                      	$_SESSION['blastName'] = $_POST['blastName'];
                      	$_SESSION['baddress'] = $_POST['baddress'];
                      	$_SESSION['bapt'] = $_POST['bapt'];
                      	$_SESSION['bcity'] = $_POST['bcity'];
                      	$_SESSION['bstate'] = $_POST['bstate'];
                      	$_SESSION['bzip'] = $_POST['bzip'];
                      	$_SESSION['bcountry'] = $_POST['bcountry'];
                      }
                      
                      echo("<html>
                      <title>XYZ Checkout</title>
                      <body>"); // this is line 318
                      include('header.php');
                          display_checkout_cart($_SESSION['cart'], false, 0);
                      
                      echo("
                      <br><br><br>
                      <table>
                      	<tr>
                      	<td width='25'></td>
                      	<td>
                      	<form action='/project/checkout.php' method='post' name='checkout'>
                      <table width='306' border='0' cellspacing='0' cellpadding='0'>
                          <tr> 
                      

                      and header.php looks like this:

                      <? 
                      echo" 
                      <body leftmargin='0' topmargin='0'> 
                      <p><img src='images/header.gif' width='650' height='150'></p> 
                      </body>"; 
                      ?> 
                      
                      

                      Thanks for the help.

                        Write a Reply...