Page 1 of 1

Sessions?

Posted: Tue Feb 28, 2006 11:52 am
by steves
The following code:

Code: Select all

<html><head>
<title>Log In to Database</title>
</head>
<body bgcolor="#FFFFFF">

<?php

session_start();
yields this error:

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /path/file.php:6) in /path/file.php on line 8

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/file.php:6) in /path/file.php on line 8

I discovered that NOTHING can go before the session_start(), so I changed the code to:

Code: Select all

<?php

session_start();
<html><head>
<title>Log In to Database</title>
</head>
<body bgcolor="#FFFFFF">
That resulted in this error:

Parse error: parse error in /path/file.php on line 5

What's wrong, and how do I fix it?

Thanks

Posted: Tue Feb 28, 2006 12:06 pm
by feyd
like before, you forgot to stop php after calling session_start().

Posted: Tue Feb 28, 2006 12:26 pm
by steves
like before?

anyway, thanks. that worked.

Posted: Tue Feb 28, 2006 12:30 pm
by chrys
Yep, it always has to go before any sort of output, even a blank line.. sometimes that can get you.

Posted: Tue Feb 28, 2006 1:02 pm
by feyd
steves wrote:like before?
I was thinking of another user, my mistake.

Posted: Tue Feb 28, 2006 1:39 pm
by neophyte
I had a header error once that took forever to figure out. I kept getting an error that said the problem was on the last line of the file which was '?>'. I figured it was an unclosed string or a missing brace somewhere above it. So I took the file apart commenting stuff out searching for that one line problematic code. Ready for the punch line? The last line was actually '?> '. That extra space after the '>' in an included file caused the header error. :lol: :lol: :lol: :lol:

Posted: Tue Feb 28, 2006 2:00 pm
by steves
This one's taking me a few minutes to figure out, too. I developed the php - something like 20 files in a tree structure - on my PowerBook G4, with MySQL 5.0.16-max and PHP 5.1.2. Everything worked BEAUTIFULLY!!

Next, I moved everything over to my server - an iMac G5 running OS X Server, with MySQL 4.1.13a and PHP 4.3.11

Figured that'd be no problem. But nothing works! I'm having to go through and debug page by page.

Does anyone know of a simple thing - I dunno, maybe there's a PHP MySQL function that's allowed in 5.0 that isn't in 4.1, or maybe theres a simple setting in php.ini that I need to change.

And by the way, I'm not comfortable enough with the shell to make changes to .ini files without very explicit instructions.

Anyone know where I can go/what I should do?