Jump to content

headers already sent


scadran

Recommended Posts

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>جزئ&#1740;ات سبد خر&#1740;د شما</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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.