Page 1 of 1

Session start error

Posted: Wed Mar 31, 2010 1:11 pm
by gisler87
Hi,

i have all of a sudden started getting this error on my webpage and after hours of trying to figure this out i could use some help.

this is the error i am getting

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/lwherry/public_html/test/includes/functions.php:1) in /home/lwherry/public_html/test/includes/header.php on line 1

all my pages

this is the code i use for the beginning of all my webpages.

Code: Select all

<?PHP session_start();?>
<html>
	<head>
		<title>Supply City</title>
		<link href="stylesheets/public.css" media="all" rel="stylesheet" type="text/css">
	</head>
	<body>
		<div id="header">
			<h1 align="center"><a href="index.php">Supply City</a></h1>
		</div>
		<div id="login">
		<?php 
		
		if($_SESSION['SESS_FIRST_NAME']==''){
				echo "<a href='login.php'>login</a>";
				echo "&nbsp &nbsp &nbsp";
				echo "<a href='register.php'>register</a";
			}else{echo "Welcome ".$_SESSION['SESS_FIRST_NAME']."&nbsp";
		           echo "<a href='account.php'>My Account</a>&nbsp";
			   echo "<a href='logout.php'>logout</a>";}
			   ?>
		</div>	
		<div id="main">
this is the code for my main page.

Code: Select all

<?php require_once("includes/connection.php"); ?>
<?php require_once("includes/functions.php"); ?>
<?php include("includes/header.php"); ?>
<?php include("includes/cat.php")?>
		
	  <td id="page">
		<h2>New Products</h2>
		<table id="tblcenter">
			<tr >
			<th></th>
			<th align="left">Product</th>
			
			<th>Date Added</th>
			<th>Price</th>
			<th>Stock Remaining</th>
			</tr>
		    <?php
		$subject_set=getNewestProduct();
			 $num = mysql_numrows($subject_set);
			 $i=0;
			 while ($i<$num){
			
			echo "<tr class=\"off\" onmouseover=\"this.className='on'\" onmouseout=\"this.className='off'\" id=\"tblrow\">";
			$id=mysql_result($subject_set, $i,0);
			$catid=mysql_result($subject_set, $i,1);
			$name=mysql_result($subject_set, $i,2);
			$desc=mysql_result($subject_set, $i,3);
			$date=mysql_result($subject_set, $i,4);
			$price=mysql_result($subject_set, $i,5);
			$stock=mysql_result($subject_set, $i,6);
			$image=mysql_result($subject_set, $i,7);
			if (strlen($desc)>90){
			$desc=substr($desc,0,90);
			$desc=$desc."...";
			}
	
			echo "<td ><a href='product.php?product=$id' id='img'><img src='$image' width='100%' height='100%'></a></td>";
			echo "<td >&nbsp<b><a href='product.php?product=$id' id='prname'>$name</a></b><br><br>&nbsp $desc<br><br></td>";
			echo "<td ><center>$date</center></td>";
			echo "<td ><center>&pound;$price</center></td>";
			echo "<td ><center>$stock</center><br><br>";
			//echo "<form method='post' action='basket.php'>";
		        //echo "<input type=hidden name='id' value='$id'>";	
		        //echo "<input type=hidden name='action' value='add'>";
			//echo "<input type='submit' name='submit' value='Add to cart' id='submit'/>";
			//echo "</form></td>";
			echo "</tr>";
			
				$i++;
			  }
		     ?>	
         </table>
         </td>
         </tr>
</table>
<?php include("includes/footer.php"); ?>
many thanks

gisler

Re: Session start error

Posted: Wed Mar 31, 2010 1:29 pm
by jbulaswad
Gisler,

Without knowing what is within your other includes I would say that you either have have a session_start() being executed in your functions.php file or some type of other output. The safest bet is to make sure that session_start() is the first method executed; include or execute it separately at the very top of your script. Separating it as another include or even creating a session class will also help you in the long term should you decide to start adding more features to your session handler.