jonnyfortis Posted June 10, 2013 Share Posted June 10, 2013 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 Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /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:1) in /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:1) in /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:1) in /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:1) in /homepages/6/d330188495/htdocs/beta/XCInc/XCart.inc on line 4 the code i have in the page is (starting at line 1) <?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 see what i am doing wrong? thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/ Share on other sites More sharing options...
trq Posted June 10, 2013 Share Posted June 10, 2013 Your calling header on lines 2, 3, 4 & 5. This sends output. Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435114 Share on other sites More sharing options...
jonnyfortis Posted June 10, 2013 Author Share Posted June 10, 2013 Your calling header on lines 2, 3, 4 & 5. This sends output. ok so what do i need to do? Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435115 Share on other sites More sharing options...
mac_gyver Posted June 10, 2013 Share Posted June 10, 2013 change your first line of code to the following so that you can determine if the problem is before the <?php tag or due to something in the required file - <?php require_once('Connections/lotties.php'); where does the error message state the output is occurring at after you make this change? Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435121 Share on other sites More sharing options...
jonnyfortis Posted June 10, 2013 Author Share Posted June 10, 2013 change your first line of code to the following so that you can determine if the problem is before the <?php tag or due to something in the required file - <?php require_once('Connections/lotties.php'); where does the error message state the output is occurring at after you make this change? one line down Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /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:1) in /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:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 5 Warning: Cannot modify header information - headers already sent by (output started at /homepages/6/d330188495/htdocs/beta/shopping-cart.php:1) in /homepages/6/d330188495/htdocs/beta/shopping-cart.php on line 6 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:1) in/homepages/6/d330188495/htdocs/beta/XCInc/XCart.inc on line 4 Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435123 Share on other sites More sharing options...
mac_gyver Posted June 10, 2013 Share Posted June 10, 2013 since the OUTPUT is still occurring on line 1 of your file, you either have some character(s) in your file before the <?php tag OR your file is saved as a UTF-8 encoded file with the Byte Order Mark characters as part of the file. make sure you have nothing before the <?php tag in your file and make sure that if you must save the file as a UTF-8 encoded file that you save it without Byte Order Mark charters or save the file as an ascii encoded file (i.e. not a UTF-8 encoded file.) Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435125 Share on other sites More sharing options...
jonnyfortis Posted June 10, 2013 Author Share Posted June 10, 2013 since the OUTPUT is still occurring on line 1 of your file, you either have some character(s) in your file before the <?php tag OR your file is saved as a UTF-8 encoded file with the Byte Order Mark characters as part of the file. make sure you have nothing before the <?php tag in your file and make sure that if you must save the file as a UTF-8 encoded file that you save it without Byte Order Mark charters or save the file as an ascii encoded file (i.e. not a UTF-8 encoded file.) i dont appear to have anything before the <?php tag a i have tried both <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> and <meta http-equiv="Content-Type" content="text/html; charset= "utf8_general_ci" /> but both are returning the same errors Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435126 Share on other sites More sharing options...
Solution mac_gyver Posted June 10, 2013 Solution Share Posted June 10, 2013 saving your file without the Byte Order Mark characters has nothing to do with a HTML <meta tag. it's how you save the file in your editor. Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435127 Share on other sites More sharing options...
jonnyfortis Posted June 10, 2013 Author Share Posted June 10, 2013 (edited) saving your file without the Byte Order Mark characters has nothing to do with a HTML <meta tag. it's how you save the file in your editor. ok i was using dreamweaver and it had the save Byte Order Mark ticked. I now longer have the error but my script isn't working for the discount script Edited June 10, 2013 by jonnyfortis Quote Link to comment https://forums.phpfreaks.com/topic/278983-mutliple-warning-cannot-modify-header-information/#findComment-1435132 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.