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
https://forums.phpfreaks.com/topic/65977-headers-already-sent/
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
https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329908
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
https://forums.phpfreaks.com/topic/65977-headers-already-sent/#findComment-329952
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.