|
-
Jan 27th, 2011, 07:10 PM
#1
Thread Starter
Frenzied Member
Sessions Problem
Hello,
I keep geting this error can you help me please.
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/markhost/public_html/index.php:3) in /home/markhost/public_html/styles/top.php on line 2
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/markhost/public_html/index.php:3) in /home/markhost/public_html/styles/top.php on line 2
This is top.php code below.
Code:
<?php
session_start();
$username = $_SESSION['username'];
$userid = $_SESSION['userid'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title; ?></title>
<link href="styles/main.css" rel="stylesheet" type="text/css"></link>
<script language="javascript" src="scripts/javascript.js"></script>
</head>
<body>
<div id='wrapper'>
<div id='header'>
<div id='status'><?php require('scripts/status.php'); ?></div>
<a href='http://www.markhost.biz/'><img src='images/banner.png'></img></a>
</div>
<div id='nav'>
<ul>
<li>
<a href="http://www.markhost.biz/">Home</a>
</li>
<li>
<a href="#">Free Download</a>
</li>
<li>
<a href="#">Buy Full Version</a>
</li>
<li>
<a href="#">F.A.Q</a>
</li>
<li>
<a href="#">Forums</a>
</li>
<li>
<a href="#">Support</a>
</li>
</ul>
</div>
<div id='content'>
come back and mark your original post as resoved if your problem is fixed
Jamie Garland
-
Jan 27th, 2011, 08:15 PM
#2
Re: Sessions Problem
The error message tells you the problem. You can't send headers (start a session) after you've output something. You output something here:
headers already sent by (output started at /home/markhost/public_html/index.php:3)
The problem lies on line 3 of index.php.
Also, extra spaces at the top of your scripts do count as output.
-
Feb 1st, 2011, 05:18 AM
#3
Re: Sessions Problem
BOM characters can also cause this problem.
If you can't find an obvious cause, try saving the file with ANSI encoding.
Delete it. They just clutter threads anyway.
-
Feb 1st, 2011, 08:47 AM
#4
Re: Sessions Problem
You can get around this by turning ON output_buffering in php.ini.
So ,
-
Feb 2nd, 2011, 03:39 AM
#5
Re: Sessions Problem
 Originally Posted by Jmacp
You can get around this by turning ON output_buffering in php.ini.
So ,
there is absolutely no reason to do this. if you program something correctly, you'll never need to use output buffering to do anything run-of-the-mill.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|