SunQuest
           MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old June 19th, 2000, 12:03 PM
harrison harrison is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2000
Posts: 1 harrison User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Cleaning a mysql table with a perl subroutine


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway