Node PHP function causing CRON not to run properly Below is my code. I have two fields.

By default, "$staticPath" equals the path of the "field_static_ad" field, and "$flashPath" equals the path of the "field_flash_ad" field.

However, when there is nothing uploaded to "field_flash_ad", I want "$flashPath" to equal the path of "field_static_ad" instead.

This code WORKS for me know, but something is going wrong when I run CRON! I don't get an error, but I can't index my site.

&lt;?php
if ($node = menu_get_object()) {  $nid = $node-&gt;nid; }

$staticPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']);

$flashPath = field_get_items('node', $node, 'field_flash_ad');

if ($flashPath) { $flashPath = file_create_url($node-&gt;field_flash_ad['und'][0]['uri']); }

else { $flashPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']); }
?&gt;


Is there something wrong with my php?
Try debug_cron module to debug the cron issue.Also I am not sure if the mentioned code is even executing on cron run.
This module provides debugging of

 fail due to programming or runtime errors
 time out (PHP, server, database)
 are very slow



  Cron Debug will also allow you to test run specific cron functions
  while not running others. This can be nice for developing cron
  functions where you don't want to run a full cron.php with all
  maintenance, alerts and other tasks every time you test your own
  function.


Also why not you putting the complete code inside the first if conditions like'

if ($node = menu_get_object()) {  
  $nid = $node-&gt;nid; 
  $staticPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']); 
  $flashPath = field_get_items('node', $node, 'field_flash_ad'); 
  if ($flashPath) {
    $flashPath = file_create_url($node-&gt;field_flash_ad['und'][0]['uri']); 
  } else {
      $flashPath = file_create_url($node-&gt;field_static_ad['und'][0]['uri']);
   }
}