Hi Mike, hi all, I solved this nasty one! Happy. Your analysis is totally correct, Mike. Every visitor who puts an item in cart for the first time will get a cookie and... receives the error on his screen. And I, ... I didn't have this error message! What did it for me was: <? session_start();
include_once("../Connections/Aurelis.php"); include_once($DOCUMENT_ROOT . "/includes/functions/get_label.php"); include_once($DOCUMENT_ROOT . "/includes/functions/countries.php"); include_once($DOCUMENT_ROOT . "/store/includes/functions/calculate_shipping.php"); include_once($DOCUMENT_ROOT . "/store/includes/functions/get_cartID.php"); $cookie = GetCartId(); --> so , i just called the function and assigned it to a variable and... gone with the wind! Thanks again Mike! Regards Fred -----Original Message----- From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED] Sent: vrijdag 18 juli 2003 18:20 To: 'frederik feys '; '[EMAIL PROTECTED] ' Subject: RE: [PHP] headers already sent and cookie problem -----Original Message----- From: frederik feys To: 'Ford, Mike [LSS]'; [EMAIL PROTECTED] Here's the URL: http://www.aurelis.org/store/cart.txt and the get_cartID: http://www.aurelis.org/store/includes/functions/get_cartID.txt -------------------------- I've only had time for a quick look, but I think I have an inkling of where your problem might be. It all seems to lie with the way you've implemented GetCartId() -- and the problem will only show up any time the cartId cookie is not already set. Basically, if the cookie is not set, GetCartId() generates a new ID and sets the cookie -- but this requires sending a header, and you can't do this once you've started output of the real page. So you must make you first call to GetCartId() *before* you send any output. Now, if we look at this fragment of code from /store/cart.txt: function ShowCart($lang) { global $connection,$lang_dir,$DOCUMENT_ROOT,$page_theme,$country_iso_code,$srch _ter m; /* ob_start(); //start buffering output */ $page_title=get_label(194,$lang,$connection); $page_tab=3; include_once($DOCUMENT_ROOT . "/header_aurelis.php"); $country_iso_code = $_GET[country_iso_code]; if($lang=="EN"){ $currency_symbol = "$ "; } else{ $currency_symbol = "€ "; } $totalCost = 0; $show_cart = @mysql_query(("select * from cart inner join items on cart.itemId = items.itemId where cart.cookieId = '" . GetCartId() . "' order by items.itemName asc"),$connection); ... we can see that you include header_aurelis.php, which presumably outputs the initial part of your HTML, before you do $show_cart = @mysql_query ... ; which includes a call to GetCartId() -- which will attempt to set the cartId cookie if it's not already set, and will fail with the "headers already sent" error. So, overall, I'd say you've got to get/set your cartId earlier in the game -- and certainly before you call or include anything that outputs actual page content. This analysis also explains why the error is intermittent -- someone who has set the cartId cookie once will probably not see the error again until after the cookie expires 30 days later! Hope this helps (and you followed my somewhat rambling explanation!) Cheers! Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php