Session errors at top of page

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Session errors at top of page

Post by danharibo »

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/razor/public_html/suf/index.php:5) in /home/razor/public_html/suf/include/session.php on line 46

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/razor/public_html/suf/index.php:5) in /home/razor/public_html/suf/include/session.php on line 46
When i view my page:

Code: Select all

<?php

include('./Function/bb_code.php');
include('Header.php'); // Include Head file
?>
<table Align="Left" >
<tr ALIGN="center"><td>Navigation</td></tr>
<tr ALIGN="center"><td>[<a href="./index.php">Home</a>]</td></tr>
</table>
<Table align="center" >
<Tr>
<td>
<?
/*THE NEW AND IMPROVED VERSION:*/
/* Should still be connected 
mysql_connect ('localhost', 'root', 'smart101') ;
mysql_select_db ('suf_site');
*/
if(isset($_GET['page']))
{
$page = $_GET['page'];
$sql = "SELECT * FROM site_stuff ORDER BY timestamp DESC LIMIT 5 ";
}
else
{

$sql = "SELECT * FROM site_stuff ORDER BY timestamp DESC LIMIT 5 ";
}
$result = mysql_query($sql) or print ("Can't select entries from table php_blog.<br />" . $sql . "<br />" . mysql_error());

while($row = mysql_fetch_array($result)) {

    $date = date("l F d Y", $row['timestamp']);

    $title = stripslashes($row['title']);
    $icon = $row['icon'];
    $entry = stripslashes($row['entry']);
	$id = $row['id'];
	$entryout = addbbcode($entry);

    ?>

    <p><strong><img src="<? echo $icon ?>" onClick="alert('Yeah, im FAT get over it! Nvm ')"> <?php echo $title; ?></strong><br /><br />
    <?php echo $entryout; ?><br /><br />
    Posted on <?php echo $date; ?>
    <? $result2 = mysql_query ("SELECT id FROM site_comments WHERE entry='$id'");
    $num_rows = mysql_num_rows($result2); ?>
<?php echo "<a href=\"viewentry.php?id=" . $id . "\">" . $num_rows . " comments</a>"; ?>
	<hr /></p>
<?
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

You cant start a session once you have sent output to the browser
danharibo
Forum Commoner
Posts: 76
Joined: Thu Aug 17, 2006 8:56 am

Post by danharibo »

Ah yes, thanks!
Post Reply