Every other night or so, I get this message:

Warning: Invalid argument supplied for foreach() in /var/www/clienthost/orthospinereps.com/httpdocs/cron/employer_alerts/mail2.php on line 15

I think it is just because I do not have any records to loop through with the foreach()?? Anyway, how can I prevent this error from displaying?

Code:

#error_reporting(E_ALL);
#echo "m here <br>\n";

$DIR = "/var/www/vhosts/orthospinereps.com/httpdocs/cron/employer_alerts";
#$DIR = ".";

require ("$DIR/../../include/ashish_functions.php");

require("$DIR/../../smarty/libs/Smarty.class.php");

$result = getLatestJobs();

//here is the line 15
foreach ($result as $row) {

//End Time= Now, Start Time = A Very Long Time ago...
$row['end_time'] = time();
$row['start_time'] = strtotime("10 September 2000");


$uid= $row['user_id'];
$sql2 = "SELECT * FROM `employers` WHERE `ID`=". $uid ." AND Validated=1 ";
$result2 = mysql_query($sql2);
$row2 = mysql_fetch_assoc($result2);
$comp_key = md5 ($row2['Password'].$uid);
$comp_key = substr($comp_key, 0,15);



#$row['start_time'] = 0;


If anybody knows how to fix this...please help me!

Thank you!
Kind Regards!