2

I am running a PHP script which inserts lines in a database every minute, using a cron job.

My provider says:

An email will be sent to this address ONLY if your cron produces output.
If no output is generated, then no email will be sent.

I am only issuing echo statements in my PHP when there is a query error. But I don't have errors, and I see the lines appearing in my DB.

Yet, I still get emails with (nearly) empty content even if I don't have errors:

Content-type: text/html

How can I prevent this? What is considered as output when running a PHP script cron job?

UPDATE

In order to get rid of the header, see: https://stackoverflow.com/questions/10723546/how-to-get-rid-of-content-type-text-html-in-php-script-output

1 Answer 1

2

Do you have any calls to header in the code? Any whitespace outside of <?php ... ?> blocks? To answer your question 'output' is anything that would be sent to the browser in non-CLI operation, like that HTTP header you're seeing.

7
  • No call to header, but what do you mean by white spaces? There are some white spaces between my PHP instructions, but I don't echo or print any... May 23, 2012 at 15:28
  • If you have something like this: <?php dosomestuff(); ?> <?php dosomethingelse(); ?> the spaces between ?> and <?php will be sent as output.
    – xofer
    May 23, 2012 at 15:31
  • No, I don't. I only have one <?php ... ?>. I think I need to find how to remove that header... May 23, 2012 at 15:32
  • Try removing the ?> at the end of the file.
    – xofer
    May 23, 2012 at 15:33
  • Just did, but it does not solve the issue May 23, 2012 at 15:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .