RE: Warnings
| From: | Brian 'Bex' Huff | Date: | Mon, 17 Feb 2003 16:08:19 +0000 |
| Subject: | RE: Warnings | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-18568@lists.php.net to get a copy of this message | ||
you guys should really search the archives for answers, this is a very common problem:
http://marc.theaimsgroup.com/?l=php-windows&w=2&r=1&s=headers+already+sent&q=b
Here's the thing... the session stuff is done with HTTP cookies. Some people do it with session vars in every URL, but most of the time its cookies.
Anyway, HTTP cookies have to be sent in the HTTP headers of the request, along with content type, content length, etc. After you send them, you can start sending HTML text.
If you try to set session vars or cookies in the middle of a PHP page, it will fail, because the HTTP headers are already set. You can only do session and header manipulation at the ABSOLUTE TOP of your PHP page. No white space whatsoever.
You can get around this limitation by setting 'output_buffering' to some number in your 'php.ini' file... most likely your dev box has this set, but your ISP does not.
--
Brian 'Bex' Huff
bex@stellent.com
Phone: 952-903-2023
Fax: 952-829-5424
> I had the same message the other day. My line 5 is where I call a
> function. I had a </table> tag as the very last line of a function but
> had it outside the closing brace } so I moved </table> inside the
> closing brace } and the problem went away.
>
> -----Original Message-----
> From: Bobo Wieland [mailto:dev@elstudion.com]
> Sent: Saturday, February 15, 2003 7:34 AM
> To: php-windows@lists.php.net
> Subject: Warnings
>
> What does this mean:
>
> Warning: Cannot send session cookie - headers already sent by (output
> started at
> /customers/pingstkyrkan.net/pingstkyrkan.net/httpd.www/fp/index.php:1)
> in
> customers/pingstkyrkan.net/pingstkyrkan.net/httpd.www/fp/index.php on
> line 5
>
> Warning: Cannot send session cache limiter - headers already sent
> (output
> started at
> /customers/pingstkyrkan.net/pingstkyrkan.net/httpd.www/fp/index.php:1)
> in
> /customers/pingstkyrkan.net/pingstkyrkan.net/httpd.www/fp/index.php on
> line
> 5
>
>
> The php-file worked perfectly well on my local machine...
>
>
> .bobo