Status
Not open for further replies.

ElitePirate

Active Member
136
2009
3
80
hi

I have stored my db details in a file called config.php


config.php

PHP:
<?php
session_start();
//error_reporting(E_ALL);
ini_set('display_errors',0);
    
    $glob['dbhost'] = "localhost";
.....
.....
.....

I have a cron file which runs perfectly fine.

Cron.php


PHP:
<?php include("inc/config.php");

$to_mail = 'myemail@gmail';
$sql=$dclass->select('*','tbl_test');
.....
.....
.....

This cron works perfectly fine. Now i need another cron file. I copied the same exact content of this cron file and created a new cron file called cron2.php and set the cron timing to every 1 minutes and i got this error in the error log

[18-Jan-2013 20:30:01] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in /home/xxxxx/public_html/xxxx/inc/config.php on line 2
[18-Jan-2013 20:30:01] PHP Warning: session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent in /home/xxxxx/public_html/xxxx/inc/config.php on line 2


I really don't understand how come if its 1 cron file its working flawlessly and if its 2 different cron files it gives this error. Can anyone suggest a work around?

Thanks
Elite
 
6 comments
Make sure that there are no blank lines/spaces at the beginning of the config.php and cron2.php
Also, make sure that you are calling include("inc/config.php"); as the first line in your php file before doing any other work.
 
Hi

I can confirm that there are no blank line at the begining of all my files and yes the 1st line is <?php include("inc/config.php");

still getting the same error.

Elite
 
Try adding a session_name in front of session_start with a different number for each cron task. Also make sure it is executing the session_destroy before exitng the php program.
Code:
session_name("Session_1");
 
this error occured cause there has space or some html code before session start to avoid this use

ob_start()

function top of the page and do not forget to call

ob_end()

bottom of the page.
 
Ignore what everyone is saying about whitespace, there clearly isn't any.

You cannot simply post partial code and expect a response.

Paste your entire code, both files, nothing removed.
 
Ignore what everyone is saying about whitespace, there clearly isn't any.

You cannot simply post partial code and expect a response.

Paste your entire code, both files, nothing removed.
I fail to understand how you are able to judge whether there is any whitespace or not if he has posted only partial code.

@OP: If this issue is still not resolved, make sure you upload the actual files and not just paste the file content, because some editors also add BOM to the file which could result in this error.
 
Status
Not open for further replies.
Back
Top