Problem with php cron job

16 posts by 2 authors in: Forums > CMS Builder
Last Post: August 6, 2014   (RSS)

  • Archived  

By nmsinc - July 29, 2014

Having an issue running a php cron job - see error below along with php file!

ERROR: "setPrefixedCookie: Can't set cookie, headers already sent! Output started in line 0."

<?php
  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/claimsca/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
  $where2 = "";
  $where2 = 'disabled = 0';
  $where = '';
  $where = 'remove_record_from_listing = 0 and status != "Final"';
  // load records
  list($listingRecords, $listingMetaData) = getRecords(array(
    'tableName'   => 'listing',
    'where'       => $where,
    'orderBy'     => 'num',
  ));
  list($accountsRecords, $accountsMetaData) = getRecords(array(
    'tableName'   => 'accounts',
    'where'       => $where2,
  ));
?>
<?php foreach ($accountsRecords as $record):?>
<?php
                $activeNum     = 0;
                $n = 0;
                ?>  
                <?php foreach ($listingRecords as $record1): ?>
                <?php $n = $n + 1;?>
                <?php if ($record1['in_adjuster'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['in_dispatcher'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['in_processor'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1[in_agent'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['i_adjuster'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['i_dispatcher'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['i_processor'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php elseif ($record1['i_agent'] == $record['num']): ?>
                <?php $activeNum = $activeNum + 1; ?>
                <?php else: ?>
                <?php $activeNum = $activeNum + 0; ?>
                <?php endif; ?>
                <?php endforeach ?>
                <?php clearstatcache();?>
                <?php
                $query = "UPDATE `{$TABLE_PREFIX}accounts` SET
                      
                                            
                      inventory_working          = $activeNum,
                      inventory_total            = $n,       
                      updatedDate                = NOW()

                      
                 WHERE num = '".mysql_escape( $record['num'] )."'";
                 mysql_query($query) or die("MySQL Error:<br/>\n". htmlspecialchars(mysql_error()) . "\n");
                 $userNum = mysql_insert_id();
exit;                 
                 ?>
                 
<?php endforeach ?>

Thanks - nmsinc

nmsinc
  • Archived  

By Dave - July 29, 2014

Hi nmsinc, 

Check for and remove any whitespace before the first <?php tag.  Output started in line 0 usually means there was something that got sent on line 0, usually spaces or enters.

And failing that, check none of the plugins you're loading have extra whitespace at the top or bottom (disabling a plugin is a quick way to check, if you don't get an error after disabling the plugin then it's that plugin).

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - July 30, 2014 - edited: July 30, 2014

Hi Dave,

I deactivated each plugin one at a time and allowed the cron job to run. I also made sure that the white spaces on the first and last lines of the cron job were removed and results were the same.

Also, if I remove the following three lines of text then I get a record access error!

  $libraryPath = 'cmsAdmin/lib/viewer_functions.php';
  $dirsToCheck = array('/home/claimsca/public_html/','','../','../../','../../../');
  foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}

Any other suggestions?

Thanks - nmsinc

nmsinc
  • Archived  

By Dave - July 30, 2014

Hi nmsinc, 

Could you email CMS/FTP login details over to dave@interactivetools.com (email, do not post login details to the forum), as well as a link to this post and the page in question on your site? I can take a quick look for you and let you know what the problem is. 

Thanks!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - August 5, 2014

Hi Dave,

I sent you two emails last week regarding this and no answer - do you have any ideas?

Thanks - nmsinc

nmsinc
  • Archived  

By Dave - August 5, 2014

Hi nmsinc, 

Sorry, looks like these got flagged as spam as a false positive (Google Apps Email).  I'll check this out now, thanks for letting me know you didn't get a response!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By Dave - August 5, 2014

I responded via email.  Can you post back here when you respond just so I can ensure I get it?  Thanks!

Dave Edis - Senior Developer
interactivetools.com
  • Archived  

By nmsinc - August 5, 2014

Hi Dave,

I just responded!

nmsinc
  • Archived  

By nmsinc - August 5, 2014

Thanks Dave I appreciate your help with this!

nmsinc

nmsinc