We take a look at Ubisoft's next iteration in the Far Cry universe to see just what is on offer
Badger Badger Badger - Far Cry 4 Reviewed
We chat with Blizzard RTS veteran Allen Dilling on the past, present and future of StarCraft!
StarCraft II: Legacy of the Void Developer Interview
The first expansion for Company of Heroes 2 has landed. How does one attack Adrennes Assault? Read our review to find out!
Company of Heroes 2: Adrennes Assault Review
What am I doing wrong?
arkter
Gold Coast, Queensland
642 posts
Cron jobs... whats wrong with this.. I'll be f***ed if I can figure out what I've done wrong...


# Delete expired files
if($c->{files_expire_access_anon} || $c->{files_expire_access_reg} || $c->{files_expire_access_prem})
{
for my $srv (@$servers)
{
my @files;
if($c->{files_expire_access_anon})
{
my $list = $db->SelectARef("SELECT f.*
FROM Files f
WHERE srv_id=?
AND f.usr_id=0
AND file_last_download < NOW()-INTERVAL ? DAY",
$srv->{srv_id},$c->{files_expire_access_anon});
push @files, @$list;
}
if($c->{files_expire_access_reg})
{
my $list = $db->SelectARef("SELECT f.*
FROM Files f, Users u
WHERE srv_id=?
AND f.usr_id=u.usr_id
AND usr_premium_expire AND file_last_download < NOW()-INTERVAL ? DAY",
$srv->{srv_id},$c->{files_expire_access_reg});
push @files, @$list;
}
if($c->{files_expire_access_prem})
{
my $list = $db->SelectARef("SELECT f.*
FROM Files f, Users u
WHERE srv_id=?
AND f.usr_id=u.usr_id
AND (usr_premium_expire IS NULL OR usr_premium_expire < NOW())
if $c->{dont_expire_premium};
AND (usr_premium_expire IS NULL OR usr_premium_expire < DATE_ADD(NOW(), INTERVAL -30 DAY) )
if $c->{dont_expire_premium};
push @files, @$list;
}


next if $#files==-1;
print"Have ".($#files+1)." files to delete from SRV=$srv->{srv_id}...\n";
$ses->DeleteFilesMass(\@files);
print"Done.
\n";
}
}



specifically:


{
my $list = $db->SelectARef("SELECT f.*
FROM Files f, Users u
WHERE srv_id=?
AND f.usr_id=u.usr_id
AND (usr_premium_expire IS NULL OR usr_premium_expire < NOW())
if $c->{dont_expire_premium};
AND (usr_premium_expire IS NULL OR usr_premium_expire < DATE_ADD(NOW(), INTERVAL -30 DAY) )
if $c->{dont_expire_premium};
push @files, @$list;

07:51pm 22/02/12 Permalink
system
Internet
--
07:51pm 22/02/12 Permalink
Nerfy
Brisbane, Queensland
5405 posts
I hear ya, but eventually you've just gotta stop asking, and accept that this is the way that you will have to live your life.

(soz, what I really meant was, maybe try stackoverflow, since I don't know what cronjobs are I suspect that it might be a niche help topic.. edit: whoa, people do know things about cron jobs!)
07:55pm 22/02/12 Permalink
Hemerage
Brisbane, Queensland
15461 posts
You forgot a comma.
08:01pm 22/02/12 Permalink
Captain Lateral
Brisbane, Queensland
4422 posts
gotta stack trace or a better description of what you're trying to achieve and what its not doing?

EDIT:
also,

push @files, @$list;
is missing a ")" at the end?

last edited by Captain Lateral at 20:04:49 22/Feb/12

last edited by Captain Lateral at 20:08:34 22/Feb/12
08:02pm 22/02/12 Permalink
teq
Brisbane, Queensland
12623 posts
SELECT f.* FROM Files f, Users u WHERE srv_id=? AND f.usr_id=u.usr_id AND (usr_premium_expire IS NULL OR usr_premium_expire < NOW())

what does that query return if you run it on the command line (presumably postgres?)
obviously replace ? with a correct srv_id

it doesn't look like you're selecting any columns from Users because you've only specified f.* and nothing for Users
08:11pm 22/02/12 Permalink
Dazhel
Gold Coast, Queensland
4459 posts
What am I doing wrong?

Using Perl.

Smart arse comments aside, it looks like you haven't terminated the string constant for the database query.
The other queries have a " at the end of the query where the rest of the code continues.

The method call to $db->SelectARef("SELECT f.* blah blah blah", x, y, z); looks to be a parameterized query, where you'd need to specify x, y, and z variables that get replaced in the query at the places marked by the question marks.
08:33pm 22/02/12 Permalink
arkter
Gold Coast, Queensland
643 posts
thanks for pointers... I'm f*****g s*** at perl and really just trying my best here....



it doesn't look like you're selecting any columns from Users because you've only specified f.* and nothing for Users


Not the problem, much love for help though

Smart arse comments aside, it looks like you haven't terminated the string constant for the database query.
The other queries have a " at the end of the query where the rest of the code continues.


Will punch myself in the face if this fixes it... will get back to you... ty again
08:55pm 22/02/12 Permalink
trillion
Brisbane, Queensland
2614 posts
for future reference you could probably have resolved this yourself if you made use of a coloured syntax highlighting text editor like emacs, vi, or notepad++ in windows
09:50pm 22/02/12 Permalink
system
Internet
--
09:50pm 22/02/12 Permalink
AusGamers Forums
Show: per page
1
This thread is archived and cannot be replied to.