scadran Posted August 21, 2007 Share Posted August 21, 2007 Hi guys My codes arw as follow: <?php // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; } $_SESSION['cart'] = $cart; ?> <html> <head> <?php echo $cart; $cart = $_SESSION['cart']; require_once('inc/functions.php'); include('config.php'); ?> <meta http-equiv="Content-Type" content="text/html; charset=windows-1256"> <link rel="stylesheet" type="text/css" href="style.css"> <title>جزئیات سبد خرید شما</title> <script type="text/javascript" language="JavaScript1.2" src="_pgtres/stmenu.js"></script> </head> <body background="images/fa_mainbg.gif"> ........... Why do i recieve tis error? Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\wamp\www\pangaan\philosophy.php:4) in C:\wamp\www\pangaan\philosophy.php on line 5 Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/ Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 is this file ran directly ? or included or open'd via any other process (other than via the browser url) Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329882 Share on other sites More sharing options...
scadran Posted August 21, 2007 Author Share Posted August 21, 2007 I am not sure what u mean ... but if u mean the philosophy.php file, then I ve opend the file via the browser ... I am running it on my own server. Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329903 Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 Have you read the big HEADER ERRORS sticky at the top of this forum? Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329907 Share on other sites More sharing options...
MadTechie Posted August 21, 2007 Share Posted August 21, 2007 well the following code is fine.. you sure your not including it or something? <?php // Start the session session_start(); // Process actions $cart = $_SESSION['cart']; $action = $_GET['action']; switch ($action) { case 'add': if ($cart) { $cart .= ','.$_GET['id']; } else { $cart = $_GET['id']; } break; case 'delete': if ($cart) { $items = explode(',',$cart); $newcart = ''; foreach ($items as $item) { if ($_GET['id'] != $item) { if ($newcart != '') { $newcart .= ','.$item; } else { $newcart = $item; } } } $cart = $newcart; } break; } $_SESSION['cart'] = $cart; ?> Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329908 Share on other sites More sharing options...
scadran Posted August 21, 2007 Author Share Posted August 21, 2007 what am i including? nothing really .... The page is displayed completely and correctly ... but i need to know why should i have that warning at the very top of the page!? is there something wrong with this part? echo $cart; $cart = $_SESSION['cart']; require_once('inc/functions.php'); include('config.php'); ?> cause this is the only part which i ve included and then recieved the warning!? Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329952 Share on other sites More sharing options...
trq Posted August 21, 2007 Share Posted August 21, 2007 is there something wrong with this part? Yes. You cannot echo ANYTHING prior to calling session_start() or header(). Once again I ask... Have you read the big HEADER ERRORS sticky at the top of this forum? Link to comment https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.