Hello,
We have a perl script that is supposed to clean one of our tables for any records that are older than 30 minutes, our problem is this, someone logs in at 11:00pm but doesn't click the logout button to be removed from the table, so someone else logs in at 1:00am, and the old person is still listed as online, I think the problem is that our subroutine is only comparing the minutes when it should also check the date and if it's not the current date, then remove it. Can someone look at the following code and show us where we went wrong.
[pre]
sub newclean{
my ($sec,$min,$hour,$mday,$mon,$year)= localtime(time);

# Table - lastlogin
# Fields: id - INT UNSIGNED NOT NULL AUTO_INCREMENT, date - DATETIME.

my $sql="SELECT ttime, MINUTE(ttime) , ttime FROM lastlogin";
my $cursor=$dbh->prepare($sql);
$cursor->execute | | die "Can't execute: $!n";

my ($id, $date, $mincheck);
while (($id, $date, $exp) = $cursor->fetchrow_array){
if (($min-$date) < 0 ) { $mincheck=$min+60; }
else { $mincheck=$min; }

if (($mincheck-$date) > 60 )
{
$sql="DELETE FROM lastlogin WHERE ttime = $exp";
$dbh->do($sql) or warn "Could not delete field where Name = $id : $!n";
}}}
[pre]

Thanks for the help
Harrison