Link to home
Start Free TrialLog in
Avatar of greatroni
greatroni

asked on

php warning in running cron job

Hi experts, I know nothing about php programming so far. I think I will learn that quick if errors keep coming like this :) . THANKS FOR HELP IN ADVANCE.
I am running cron job and getting this error:

PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in /home/inter117/public_html/inc/inc.header.php on line 4
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cookie - headers already sent in <b>/home/inter117/public_html/inc/inc.header.php</b> on line <b>4</b><br />
PHP Warning:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/inter117/public_html/inc/inc.header.php:4) in /home/inter117/public_html/inc/inc.header.php on line 4
<br />
<b>Warning</b>:  session_start() [<a href='function.session-start'>function.session-start</a>]: Cannot send session cache limiter - headers already sent (output started at /home/inter117/public_html/inc/inc.header.php:4) in <b>/home/inter117/public_html/inc/inc.header.php</b> on line <b>4</b><br />


CRON JOB FILE IS AS FOLLOWS:

<?php
/**
 * Regulars permission for mediafiles access
 */

// Detect DOCUMENT_ROOT var
$_document_root = substr( $argv[0], 0, -14 );

// requiring system headers
require_once( $_document_root.'/configs.php' );
require_once( $_document_root.'/inc/inc.header.php' );


/* --- Profile Timeout Logout --- */

require_once( DIR_APP.'app.profile.php' );

$_query = "SELECT `profile_id` FROM `".TBL_PROFILE_ONLINE."` WHERE `expiration_time`<".time()."";
$_logouted_profiles = MySQL::fetchArray( $_query );

foreach ( $_logouted_profiles as $_profile )
      appProfile::logoutProfile( $_profile['profile_id'] );
      
/* --- Mass mailing --- */

require_once( DIR_APP.'app.mail.php' );

Mail::sendMessages();

/* --- Delete expired Profile register invitations --- */

$_query = "DELETE FROM `".TBL_PROFILE_REGISTER_INVITE_CODE."` WHERE `expiration_date`<'".time()."'";
MySQL::fetchResource( $_query );


/* --- Delete expired email verifications --- */

$_query = "DELETE FROM `".TBL_PROFILE_EMAIL_VERIFY_CODE."` WHERE `expiration_date`<'".time()."'";
MySQL::fetchResource( $_query );

/* --- Delete expired Captcha table --- */

$_query = "DELETE FROM `".TBL_CAPTCHA."` WHERE `expiration_time`<'".time()."'";
MySQL::fetchResource( $_query );

/* --- Delete expired profiles' memberships --- */
require_once( DIR_INC.'class.language.php' );
require_once( DIR_APP.'app.membership.php' );


Avatar of Harisha M G
Harisha M G
Flag of India image

Hi greatroni, the problem is not in this file. Goto inc.header.php and see whether there is anything output before session_start(); Anything: a space, a newline, a tab or any other output can cause this error


---
Harish
Avatar of greatroni
greatroni

ASKER

I dont get it. Here is code for inc.header.php
Thanks Harish for looking at it.




<?php

session_name( 'skadate' );
session_start();

require_once( 'inc.debug.php' );
require_once( 'fnc.system.php' );
require_once( 'class.mysql.php' );
require_once( 'fnc.custom.php' );
require_once( 'fnc.profile.php' );
require_once( 'fnc.datetime.php' );
require_once( 'fnc.navigation.php' );
require_once( 'fnc.upload.php' );
require_once( 'fnc.media.php' );
require_once( 'fnc.sql_placeholder.php' );

if( ini_get( 'magic_quotes_gpc' ) )
{
      $_GET = clearSlashes( $_GET );
      $_POST = clearSlashes( $_POST );
      $_COOKIE = clearSlashes( $_COOKIE );
      $_ENV = clearSlashes( $_ENV );
}


// database TBL_ constants
define( 'TBL_LANG', DB_PREFIX . 'language' );
define( 'TBL_LANG_KEY_TYPE', DB_PREFIX . 'language_key_type' );
define( 'TBL_LANG_KEY', DB_PREFIX . 'language_key' );
define( 'TBL_LANG_VALUE', DB_PREFIX . 'language_value' );
define( 'TBL_PROF_FIELD', DB_PREFIX . 'profile_field' );
define( 'TBL_PROFILE_FIELD', DB_PREFIX . 'profile_field' );
define( 'TBL_PROF_FIELD_PAGE', DB_PREFIX . 'profile_field_page' );
define( 'TBL_PROF_FIELD_PAGE_LINK', DB_PREFIX . 'link_profile_field_page' );
define( 'TBL_PROF_FIELD_MATCH_LINK', DB_PREFIX . 'link_profile_field_match' );
define( 'TBL_PROF_FIELD_SECTION', DB_PREFIX . 'profile_field_section' );
define( 'TBL_PROF_FIELD_VALUE', DB_PREFIX . 'profile_field_values' );
define( 'TBL_PROFILE', DB_PREFIX . 'profile' );
define( 'TBL_PROFILE_EXTEND', DB_PREFIX . 'profile_extended' );
define( 'TBL_PROFILE_ONLINE', DB_PREFIX . 'profile_online' );
define( 'TBL_PROFILE_PHOTO', DB_PREFIX . 'profile_photo' );
define( 'TBL_CONFIG', DB_PREFIX . 'config' );
define( 'TBL_CONFIG_VALUES', DB_PREFIX . 'config_values' );
define( 'TBL_PRESS_CATEGORY', DB_PREFIX . 'press_category' );
define( 'TBL_PRESS_POST', DB_PREFIX . 'press_post' );
define( 'TBL_LINK_PRESS_CATEGORY_POST', DB_PREFIX . 'link_press_category_post' );
define( 'TBL_PRESS_IMAGE', DB_PREFIX . 'press_image' );
define( 'TBL_MEMBERSHIP', DB_PREFIX . 'membership' );
define( 'TBL_MEMBERSHIP_TYPE', DB_PREFIX . 'membership_type' );
define( 'TBL_MEMBERSHIP_TYPE_PLAN', DB_PREFIX . 'membership_type_plan' );
define( 'TBL_MEMBERSHIP_LINK_MEMBERSHIP_TYPE_SERVICE', DB_PREFIX . 'link_membership_type_service' );
define( 'TBL_MEMBERSHIP_SERVICE', DB_PREFIX . 'membership_service' );
define( 'TBL_MEMBERSHIP_CLAIM', DB_PREFIX . 'membership_claim' );
define( 'TBL_FIN_PAYMENT_PROVIDERS', DB_PREFIX . 'fin_payment_provider' );
define( 'TBL_FIN_SALE_INFO', DB_PREFIX . 'fin_sale_info' );
define( 'TBL_FIN_SALE', DB_PREFIX . 'fin_sale' );
define( 'TBL_FIN_REFUND', DB_PREFIX . 'fin_refund' );
define( 'TBL_MSG', DB_PREFIX . 'message' );
define( 'TBL_VKISS_TPL', DB_PREFIX . 'vkiss_template' );
define( 'TBL_TMP_PR_LIST', DB_PREFIX . 'tmp_profile_list' );
define( 'TBL_LINK_PR_LIST_PR', DB_PREFIX . 'tmp_link_profile_list_profile' );
define( 'TBL_MENU_ITEM', DB_PREFIX . 'menu_item' );
define( 'TBL_DOCUMENT', DB_PREFIX . 'document' );
define( 'TBL_LINK_MENU_ITEM_MEMBERSHIP', DB_PREFIX . 'link_menu_item_membership_type' );
define( 'TBL_PROFILE_PHOTO_ACCESS', DB_PREFIX . 'profile_photo_access' );
define( 'TBL_PROFILE_PHOTO_RATE', DB_PREFIX . 'profile_photo_rate' );
define( 'TBL_FEATURE', DB_PREFIX . 'feature' );
define( 'TBL_PROFILE_RATE', DB_PREFIX . 'profile_rate' );
define( 'TBL_PROFILE_BLOCK_LIST', DB_PREFIX . 'profile_block_list' );
define( 'TBL_PROFILE_HOTLIST', DB_PREFIX . 'profile_hotlist' );
define( 'TBL_PROFILE_FRIEND_LIST', DB_PREFIX . 'profile_friend_list' );
define( 'TBL_CAPTCHA', DB_PREFIX . 'tmp_captcha' );
define( 'TBL_TAG', DB_PREFIX . 'tag' );
define( 'TBL_LINK_TAG_PROFILE', DB_PREFIX . 'link_tag_profile' );
define( 'TBL_TAG_FILTER', DB_PREFIX . 'tag_filter' );
define( 'TBL_ADS_TEMPLATE', DB_PREFIX . 'ads_template' );
define( 'TBL_ADS_POSITION', DB_PREFIX . 'ads_position' );
define( 'TBL_LINK_ADS_PAGE_POSITION', DB_PREFIX . 'link_ads_page_position' );
define( 'TBL_LINK_ADS_BINDING_TPL', DB_PREFIX . 'link_ads_binding_template' );
define( 'TBL_EVENT', DB_PREFIX . 'event' );
define( 'TBL_PROFILE_MEDIA', DB_PREFIX . 'profile_media' );
define( 'TBL_POLL', DB_PREFIX . 'poll' );
define( 'TBL_POLL_ANSWER', DB_PREFIX . 'poll_answer' );
define( 'TBL_POLL_CUSTOM_ANSWER', DB_PREFIX . 'poll_custom_answer' );
define( 'TBL_POLL_POSITION', DB_PREFIX . 'poll_position' );
define( 'TBL_POLL_VOTE', DB_PREFIX . 'poll_vote' );
define( 'TBL_PENDING_IM', DB_PREFIX . 'im_pending' );
define( 'TBL_MAIL', DB_PREFIX.'mail' );
define( 'TBL_PROFILE_REGISTER_INVITE_CODE', DB_PREFIX.'profile_registration_invite_code' );
define( 'TBL_AFFILIATE', DB_PREFIX.'affiliate' );
define( 'TBL_AFFILIATE_PLAN', DB_PREFIX.'affiliate_plan' );
define( 'TBL_AFFILIATE_REGISTRATION', DB_PREFIX.'affiliate_registration' );
define( 'TBL_AFFILIATE_SUBSCRIPTION', DB_PREFIX.'affiliate_subscription' );
define( 'TBL_AFFILIATE_TRAFFIC', DB_PREFIX.'affiliate_traffic' );
define( 'TBL_AFFILIATE_VISIT', DB_PREFIX.'affiliate_visit' );
define( 'TBL_AFFILIATE_SITE', DB_PREFIX.'affiliate_site' );
define( 'TBL_AFFILIATE_PAYMENT', DB_PREFIX.'affiliate_payment' );
define( 'TBL_AFFILIATE_EMAIL_VERIFY_CODE', DB_PREFIX.'affiliate_email_verification_code' );
define( 'TBL_LOCATION_COUNTRY', DB_PREFIX.'location_country' );
define( 'TBL_LOCATION_STATE', DB_PREFIX.'location_state' );
define( 'TBL_LOCATION_CITY', DB_PREFIX.'location_city' );
define( 'TBL_LOCATION_ZIP', DB_PREFIX.'location_zip' );
define( 'TBL_LOCATION_REGION', DB_PREFIX.'location_region' );
define( 'TBL_LOCATION_STATE_LETTERS', DB_PREFIX.'location_state_letters' );
define( 'TBL_PROFILE_EMAIL_VERIFY_CODE', DB_PREFIX.'profile_email_verification_code' );
define( 'TBL_BLOCK_IP', DB_PREFIX.'block_ip' );
define( 'TBL_SMILE', DB_PREFIX.'smile' );


MySQL::connect();

$_CONFIG = MySQL::fetchArray( "SELECT `name`,`value` FROM `".TBL_CONFIG."` WHERE 1", 1 );
// Path constant
define( 'PATH_HOME', strchr( substr( URL_HOME, strlen( 'http://' ) ), '/' ) );

// DIR_ constants
define( 'DIR_INC', DIR_ROOT . 'inc/' );
define( 'DIR_APP', DIR_ROOT . 'app/' );
define( 'DIR_CMP', DIR_ROOT . 'components/' );
define( 'DIR_LANG_CACHE', DIR_ROOT . '_cache/' );
define( 'DIR_CACHE', DIR_ROOT . '_cache/' );
define( 'DIR_SMARTY', DIR_ROOT . 'smarty/' );
define( 'DIR_LAYOUTS', DIR_ROOT . 'layouts/' );
define( 'LAYOUT', getLayout() );

define( 'DIR_CURR_LAYOUT', DIR_LAYOUTS . LAYOUT . '/' );
define( 'DIR_MAIN_CSS', DIR_CURR_LAYOUT . 'css/' );
define( 'DIR_CMP_TPL', DIR_CURR_LAYOUT . 'components/' );
define( 'DIR_CONTENT_TPL', DIR_CURR_LAYOUT . 'content/' );
define( 'DIR_ADMIN', DIR_ROOT . 'admin/' );
define( 'DIR_ADMIN_INC', DIR_ROOT . 'admin/inc/' );
define( 'DIR_AFFILIATE', DIR_ROOT . 'affiliate/' );
define( 'DIR_AFFILIATE_INC', DIR_ROOT . 'affiliate/inc/' );
define( 'DIR_UPL_IMG', DIR_ROOT . 'images/' );
define( 'DIR_UPL_MEDIA', DIR_ROOT . 'media/' );
define( 'DIR_MASTER_PAGE', DIR_CURR_LAYOUT . 'master_page/' );
define( 'DIR_AJAX', DIR_ROOT . 'ajax/' );
define( 'DIR_CAPTCHA', DIR_ROOT . 'captcha/' );
define( 'DIR_LANG_DUMP', DIR_CACHE.'lang_dump/' );
define( 'DIR_SERVICE_AUTOCROP', DIR_ROOT.'services/autocrop/' );

// For Smarty class
define( 'SMARTY_DIR', DIR_ROOT . 'smarty/' );

// URL_ constants
define( 'URL_CMP_TPL', URL_HOME . 'layouts/' . LAYOUT . '/components/' );
define( 'URL_CONTENT', URL_HOME . 'layouts/' . LAYOUT . '/content/' );
define( 'URL_MAIN_JS', URL_HOME . 'inc/js/' );
define( 'URL_ADMIN', URL_HOME . 'admin/' );
define( 'URL_ADMIN_IMG', URL_HOME . 'admin/img/' );
define( 'URL_ADMIN_CSS', URL_ADMIN. 'css/' );
define( 'URL_ADMIN_JS', URL_ADMIN. 'js/' );
define( 'URL_AFFILIATE', URL_HOME . 'affiliate/' );
define( 'URL_AFFIILATE_IMG', URL_AFFILIATE . 'img/' );
define( 'URL_AFFILIATE_CSS', URL_AFFILIATE. 'css/' );
define( 'URL_AFFILIATE_JS', URL_AFFILIATE. 'js/' );
define( 'URL_MEMBER', URL_HOME . 'member/' );
define( 'URL_UPL_IMG', URL_HOME . 'images/' );
define( 'URL_UPL_MEDIA', URL_HOME . 'media/' );
define( 'URL_LAYOUT_IMG', URL_HOME . 'layouts/' . LAYOUT . '/img/' );
define( 'URL_PRESS', URL_HOME . 'press/' );
define( 'URL_MASTER_PAGE', URL_HOME . 'layouts/' . LAYOUT . '/master_page/' );
define( 'URL_AJAX', URL_HOME . 'ajax/' );
define( 'URL_CAPTCHA', URL_HOME . 'captcha/' );
define( 'URL_FLASH_CHAT', URL_HOME . 'flashchat/' );

// remote servers
define( 'URL_FLASH_SERVER', 'rtmp://www.dotsilver.com/' );

// autocrop
define('AUTOCROP_SERVICE_URL', 'http://crop.goofytalk.com/crop.asmx');
define('AUTOCROP_SERVICE_LOGIN', getConfig( 'autocrop_username' ) );
define('AUTOCROP_SERVICE_PASSWORD', getConfig( 'autocrop_password' ));

// Define layout.css path
define( 'LAYOUT_CSS', URL_HOME . 'layouts/' . LAYOUT . '/layout.css' );

// UPL_IMG_PREF constants
define( 'UPL_IMG_PREF_PRESS', 'press_' );

// systems define
define( 'SEARCH_RESULT_MAX', 500 );

// Max quality of uploaded images
define( 'UPLOAD_IMG_QUALITY', 95 );

// limit of sending emails for one by cron
define( 'MAIL_SEND_LIMIT', 30 );

define( 'MAX_SQL_BIGINT', '0xffffffffffffffff' );

define( 'PROFILECARD_TRUNCATE_HEADLINE_SYM', 75 );
define( 'PROFILECARD_TRUNCATE_GENERAL_DESCRIPTION_SYM', 600 );

define( 'ONE_MB_INBYTE', 1024*1024 );

define( 'PACKAGE_VERSION', '5.0.774' );

// requiring layout configs
require_once( DIR_CURR_LAYOUT . 'layout.php' );

require_once( DIR_APP.'app.affiliate.php' );
appAffiliate::AffiliateProgram();

// initiialize array with profile fields info
require_once( DIR_APP.'global.pr_fields.php' );

// check profile inline status
UpdateProfileActivity();

// navigate
ProfileNavigation( $document_key );


?>
Do you have space or newline character above <?
if you use a simple php command in crontab to run a php script then you might have the error with session_start();

try to use a "wget" and that should not give you the "WARNING" from php.

edit crontab

crontab -e

01 01 * * * wget "http://localhost/some/script.php?var=somevalue" -o /dev/null
There is no space or newline above <?
I can run cron job only with the interface provided by hosting service.
does the page give an error when opening in a browser or does the error happen when you are running it in crontab?

both the errors are two different events
when php script run in crob job setting. result(error in this case) is sent to me by email.
ASKER CERTIFIED SOLUTION
Avatar of ygoutham
ygoutham
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial