Results 1 to 4 of 4

Thread: Warning: Cannot modify header information

  1. #1
    Join Date
    Nov 2011
    Posts
    44
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Warning: Cannot modify header information

    I have been looking through the forum regarding this a alot of peoples problems are white space or the session needs to go at the top of the page before ANYTHING else.

    i am getting the following errors

    PHP Code:
    WarningCannot modify header information headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 2

    Warning
    Cannot modify header information headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 3

    Warning
    Cannot modify header information headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 4

    Warning
    Cannot modify header information headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 5

    Warning
    session_start() [function.session-start]: Cannot send session cache limiter headers already sent (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1in /homepages/6/d330188495/htdocs/beta/XCInc/XCart.inc on line 4 
    the code i have in the page is (starting at line 1)

    PHP Code:
    <?php require_once('Connections/lotties.php');
    header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");                // Date in the past
    header ("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT"); // always modified
    header ("Cache-Control: no-cache, must-revalidate");              // HTTP/1.1
    header ("Pragma: no-cache");        

    if (!
    function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      if (
    PHP_VERSION 6) {
        
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      }

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }


    if ((isset(
    $_POST["MM_update"])) && ($_POST["MM_update"] == "form2")) {
      
    $updateSQL sprintf("UPDATE LOTTIE_voucher SET vouchCode=%s WHERE vouchID=%s",
                           
    GetSQLValueString($_POST['vouchCode'], "text"),
                           
    GetSQLValueString($_POST['vouchID'], "int"));

      
    mysql_select_db($database_lotties$lotties);
      
    $Result1 mysql_query($updateSQL$lotties) or die(mysql_error());
    }


    // *** X Shopping Cart ***
    $useSessions true;
    $XCName "LottieJakeCart";
    $XCTimeout 30;
    $XC_ColNames=array("ProductID","Quantity","Name","Price","Stock","Total");
    $XC_ComputedCols=array("","","","","","Price");
    require_once(
    'XCInc/XCart.inc');

    mysql_select_db($database_lotties$lotties);
    $query_rsVoucher "SELECT * FROM LOTTIE_vouchercode";
    $rsVoucher mysql_query($query_rsVoucher$lotties) or die(mysql_error());
    $row_rsVoucher mysql_fetch_assoc($rsVoucher);
    $totalRows_rsVoucher mysql_num_rows($rsVoucher);

    // *** Update contents of Shopping Cart *** 
    require_once('XCInc/XCupdateAction.inc');
    if (isset(
    $_POST["Quantity"])) {
      
    $XC_UpdateRedirect "shopping-cart.php";
      
    $values $_POST["Quantity"];
      require_once(
    'XCInc/UpdateXCart.inc');
    }

    // *** Empty XCart ***
    if (isset($_SERVER["QUERY_STRING"])) {
      
    $XC_EmptyCartLink $_SERVER["PHP_SELF"] . "?" htmlentities($_SERVER["QUERY_STRING"]) . "&XC_EmptyCart=1";
    } else {
      
    $XC_EmptyCartLink $_SERVER["PHP_SELF"] . "?XC_EmptyCart=1";
    }
    if (isset(
    $_GET["XC_EmptyCart"]) && ($_GET["XC_EmptyCart"] == "1")) {
      
    $XC_EmptyCartRedirect "shopping-cart.php";
      require_once(
    'XCInc/XCemptyRedirect.inc');
    }

    // *** Repeat XCart region *** (do not remove this label) 

    // voucher code
    if (isset($_POST['vouchCode']) && $_POST['vouchCode'] == $row_rsVoucher['VCode']) {
      
    $mycode $row_rsVoucher['VCode'];
      
    $spos strpos($mycode"c");
      if (
    $spos !== false) {
        
    $myvalue substr($mycode$spos+1);
        
    $myvalue $XCart_sumTotal $myvalue 100;
      } else {
        
    $spos strpos($mycode"p");
        if (
    $spos !== false) {
          
    $myvalue substr($mycode$spos+1);
        }
      }
      
    $myTotal $XCart_sumTotal $myvalue;
      
    $_SESSION['vouchCode'] = $myvalue;
    } else unset(
    $_SESSION['vouchCode']);

    function 
    DoFormatCurrency($num,$dec,$sdec,$sgrp,$sym,$cnt) {
      
    setlocale(LC_MONETARY$cnt);
      if (
    $sdec == "C") {
        
    $locale_info localeconv();
        
    $sdec $locale_info["mon_decimal_point"];
        
    $sgrp $sgrp!="" $locale_info["mon_thousands_sep"] : "";
        
    $sym $cnt!="" $locale_info["currency_symbol"] : $sym;
      }
      
    $thenum $sym.number_format($num,$dec,$sdec,$sgrp);
      return 
    $thenum;
    }
    ?>

    the code is the shopping cart with the ability to add a discount vouchers for example

    lot123p10

    would be %10 of the total

    can anyone advise me please

    thanks in advance

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    1,998
    Thanks
    16
    Thanked 315 Times in 313 Posts
    Blog Entries
    12

    Default

    My first thought was to do with BOM, so I started formulating an answer;

    Could be down to file encoding? BOM characters can sometimes be introduced at the start of your file depending on how your editor is setup to handle file encoding. For example, UTF-8 can insert something that looks like "  " right before the opening <?php tag, so try saving it in ANSI format. In Windows you can do that in good ol' Notepad - File >> Save As >> click the Encoing: dropdown and choose ANSI.
    Then I wondered about the require_once "Connection/lotties.php" file and the "shopping-cart.php" file that its pulling in, so I Googled them to see if I could download a copy to examine. I found your post in another forum: http://forums.phpfreaks.com/topic/27...r-information/

    I see that you are already receiving help from there so I will leave the guys over at the other forum to assist you further. It just makes more sense than having us all spend time on the same issue.
    Focus on Function Web Design | Latest News RSS | Facebook | Twitter |
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps |
    The only limit to creativity is imagination: JemCon.org

  3. #3
    Join Date
    Nov 2011
    Posts
    44
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Beverleyh View Post
    My first thought was to do with BOM, so I started formulating an answer;



    Then I wondered about the require_once "Connection/lotties.php" file and the "shopping-cart.php" file that its pulling in, so I Googled them to see if I could download a copy to examine. I found your post in another forum: http://forums.phpfreaks.com/topic/27...r-information/

    I see that you are already receiving help from there so I will leave the guys over at the other forum to assist you further. It just makes more sense than having us all spend time on the same issue.
    yes sorry about that. i got it sorted regarding the BOM. thanks for your time. i don't know what's best to do in this circumstance (should i edit this post to show the answer?) or try to stick to one forum?

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 517 Times in 503 Posts
    Blog Entries
    5

    Default

    Nothing to be sorry about. Posting on multiple forums, IMO, is perfectly acceptable - as long as you're not just spamming to see who will do the work for you fastest. (Not an accusation; just a contrasting example .)

    If you've got a solution, then yeah, post it here too. It makes the thread more helpful to future readers.

Similar Threads

  1. Accordion header anchor link work while header is expanded
    By ngguh in forum Dynamic Drive scripts help
    Replies: 3
    Last Post: 05-10-2012, 07:11 PM
  2. Replies: 3
    Last Post: 12-14-2011, 01:02 AM
  3. On scroll header collapse to smaller sticky header
    By danielmeade in forum JavaScript
    Replies: 3
    Last Post: 07-17-2011, 12:28 PM
  4. php header warning help please
    By Moshambi in forum PHP
    Replies: 6
    Last Post: 08-29-2008, 05:41 PM
  5. Replies: 6
    Last Post: 09-07-2007, 12:53 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •