FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » cron job and headers sent error
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: cron job and headers sent error [message #182776 is a reply to message #182773] Mon, 09 September 2013 11:29 Go to previous message
Richard Yates is currently offline  Richard Yates
Messages: 86
Registered: September 2013
Karma:
Member
On Sun, 8 Sep 2013 21:09:22 +0000 (UTC), Denis McMahon
<denismfmcmahon(at)gmail(dot)com> wrote:

> On Sun, 08 Sep 2013 06:36:45 -0700, Richard Yates wrote:
>
>> I have a script that runs automatically every night that shortens some
>> tables. It has been working fine (Actually still is doing what it is
>> supposed to). However I started getting an email warning notice when it
>> runs. In says headers have already been sent in line two of the database
>> Connection script that is included.
>
>
>> ------- Connections/gleanslo.php
>>
>> <?php if(!isset($_SESSION)) session_start(); if($_SERVER["SERVER_NAME"]
>> == "localhost" && $_SERVER["SERVER_ADDR"]
>> == "127.0.0.1") {
>
> The initial blank line causes headers to be output in an http context,
> and then the start of the document is sent (in this case, a blank line).
>
> The session_start() normally triggers a session cookie which is part of
> the headers.
>
> The error message is saying "I met a condition that requires me to send a
> header (session_start() requiring that I send a session cookie) but I've
> finished sending headers and started sending the document body already.
>
> Easiest solution is to get rid of the blank line at the top of the file.
> More complex solution would be to do the above (which may need doing
> anyway) plus turn off the session code if you're not running in an http
> context (ie for the cron job).

Thanks. There is no blank line at the top of the file. The line:
'------- Connections/gleanslo.php and the space after it 'are a
separator I put in the post to the make the different code sections
clear.

I removed the if(!isset($_SESSION)) session_start(); line from the
connection script that is called by the cron job and did not get an
error warning this mornng.

Thank you to all that responded.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: [Mac OS X ML] how to install MongoDB driver
Next Topic: Trouble-shooting a script that doesn't retuen HTML
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 12:37:12 GMT 2024

Total time taken to generate the page: 0.04100 seconds