Hello everyone. I have an issue that can't figure out, and was wondering if someone can help me with it. I offer mySQL based e-mail account to my users. The actual e-mails are stored in a text based directory. Sometimes when the e-mail is put in the trashcan, it actually deletes the e-mail folder, so when the user goes to clear the trash, it doesn't find the referred folder/file, and gives ISE. Looking at the below subroutine, can anyone please tell me what I can do to fix this?
I basically want to check for the e-mail directory or the file, and if it doesn't exist, simply ignore it, and delete the ID from the database. Thanks so much sub deleteemails { my $self = shift; my $emails = shift; my $whereE = undef; my $whereA = undef; # print "Content-Type: Text/Html\n\n"; foreach my $id (@$emails) { if ((! $id) || ($id =~ /\D/)) {next;} my $qid = $self->{_dbobj}->quote($id); if ($self->{_StoragePath} !~ /\w/) { die("StoragePath does not contain a useful value") } #deletes all files in EmailID Directory (Email.txt and all attachment files) my $EmailDir = "$self->{_StoragePath}/$self->{_UserID}/$id"; if (! -d $EmailDir) { die("$EmailDir is not a directory"); return} opendir (EMAIL, "$EmailDir") or die("Can't open directory $EmailDir $!"), return; while(my $files = readdir(EMAIL)) { if ($files =~ /\w/) { if (! -e "$EmailDir/$files") { die("$EmailDir/$files does not exist") } unlink "$EmailDir/$files" or die("Can't delete file: $EmailDir/$files $!"); $whereE .= "EmailID = $qid OR "; } } closedir(EMAIL); rmdir($EmailDir) or die("Can't delete directory: $EmailDir $!"); } $whereE =~ s/ OR $//; if ($whereE){ my $UserID = $self->{_dbobj}->quote($self->{_UserID}); my $query = "DELETE FROM EMAILS WHERE $whereE AND UserID = $UserID"; my $sdb = $self->{_dbobj}->prepare($query); $sdb->execute; $query = "DELETE FROM ATTACHMENTS WHERE $whereE"; $sdb = $self->{_dbobj}->prepare($query); $sdb->execute; } } --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php