/    Sign up×
Community /Pin to ProfileBookmark

Fixed problem to a program that runs as a cron job every night at 12AM

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!

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@MindzaiSep 29.2009 — It's impossible to say any more than the error message is already telling you. The getLatestJobs() function is not returning an array. That's the place to start looking.
Copy linkTweet thisAlerts:
@justice2authorSep 29.2009 — Thanks a lot. I will look.
×

Success!

Help @justice2 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...