session start

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

FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

session start

Post by FireElement »

:cry: I keep getting the following errors :(


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at localhost/homepage/index.php:2) in localhost/links.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at localhost/homepage/index.php:2) in localhost/links.php on line 2



I cant understand it?? I make sure session_start is in my header(links.php) this gets included on every page. It is at the top on line one and i keep getting the above errors? What am I doing wrong?

Code: Select all

<?php 
session_start();
?>
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

hellpppppppp!!!

Post by FireElement »

I now taken it out of links.php and put it on first like of my index file in hope this world work.

Code: Select all

<?php session_start(); require("links.php"); ?>
I still get the following errors?


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at localhost/index.php:1) in localhost/index.php on line 1

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at localhost/index.php:1) in localhost/index.php on line 1


I really dont know why its not working :(
Any thing would be great thanks!!!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Search (everywhere) for the phrase "headers already sent"


It comes up quite a bit.
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

:(

Post by FireElement »

I have read:

http://uk3.php.net/function.session_start

I tried putting header at top so nothing calling out else before I dont understand why this error is still happening it does not make sense. The only php I have on my index page is start_session and and a couple of includes which only call html pages.

I really dont get it. This is my page

Code: Select all

<php start_session();

include 'links.php'; ?>

general html code
</body
</html>
links.php basically is this:

Code: Select all

<html>
<head>
<title>my site</title>
//call java files
//call css files
</head>
<body>
<a href="p1">p1</a> | 
<a href="p2">p2</a> | 
<a href="p3">p3</a>
So basically start session is called before anything else. Everytime! I dont get whats messing up?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's probably not at the top of the page source.
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

Post by FireElement »

feyd wrote:It's probably not at the top of the page source.
What you mean? The page source would look like this if I took out include. I really dont get this....

<?php start_session();
?>
<html>
<head>
<title>my site</title>
//call java files
//call css files
</head>
<body>
<a href="p1">p1</a> |
<a href="p2">p2</a> |
<a href="p3">p3</a>

general html code...

</body>
</html>
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

You need to ensure there is no HTML, text or whitespace prior to the starting PHP tag. Examples of whitespace: spaces, carriage returns, tabs, line feeds, vertical tabs...
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

Post by FireElement »

Am not sure what the hell is going on in my furry I decided to call the same form in to a basic html page. To see if it would work. It seems to work.... I dont understand why it works here.... Its neally the same as my other page...

I have even taken out most the requests out the other page and made it like this page removing the links.php and just sticking what is in this page on the page its still bringing the error... crazy!

Code: Select all

<?php 
session_start();
?>
<html>
<head>

<title>Kenjy</title>

<script language="JavaScript" src="calander/CalendarPopup.js"></script>
<script language="JavaScript">document.write(getCalendarStyles());</script>
<script type="text/javascript">

</head>
<body>
<?php

include "form.php";

?>
</body>
</html>
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

This is fuked up

Post by FireElement »

right so I removed all requests right... basically the page is empty i have start_session at top haha thats it error lmao this weird am total confused....
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Can you put the file(s) online somewhere they can be accessed (and not parsed)?
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

Post by FireElement »

I just

<?php start_session ?>

<?php /*

all the page

*/ ?>

I still get the following error? Am total confused?

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at localhost/share-tips/index.php:1) inlocalhost/share-tips/index.php on line 1
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

That is a bit odd. Why would it say that the output started in index.php if you're on links.php? My guess is you're including this in the index file.

Try not using closing ?> tags at the end of your files, and make sure there's nothing (nothing!) before the starting <?php tag on both pages.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

Post by FireElement »

unfortunaly I cant put the actual pages up.... normal that would be the first thing I did but as my mate wants no one to know his idea he said not to disscluse any thing on it.... I dont know what to do .... I cant work it out at all
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Then I guess you are stuck.

By the way, please don't attempt to bypass the swear filter again.
FireElement
Forum Commoner
Posts: 86
Joined: Wed Oct 17, 2007 6:03 pm

Post by FireElement »

ok this is so messed up I just put a page with only the following up!

<?php start_session ?>

its located http://www.domain.com/share-tips/index.php

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /data01/mlouret/public_html/share-tips/index.php:1) in /data01/mlouret/public_html/share-tips/index.php on line 1
Post Reply