Hello I'm have a problem with deleting a record, I'm using "M U L T I P L E F I L E U P L O A D Written: 28 Jun 2000".
Mod based on a script created by Jeff Carnahan jeffc@terminalp.com Adapted for use by DBMan by JPDeni deni@jpdeni.com Integration with DBMan script by Jim Kangosjärvi Jim.Kangosjarvi@Abc.se
If I delete a record that has A photo with it. the mod works fine.
But if I delete a record that dose not have a photo with it I get a error.
I tried a few things to see if it would work, and this what I came up with.
In my "sub delete_records" if I put this --
$delete_list{$data[$db_key_pos]} ? #
($delete_list{$data[$db_key_pos]} = 0) : #
($output .= $line . "\n");
The record would delete, but the photo would stay on the server.
If I replace it with this --
if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
else { $output .= $line . "\n"; }
It will delete a record that has A photo with it.
But if I delete a record that dose not have a photo with it I get a error.
I also tried this fix I found on this site from LoisC
######### changed for file upload mod ###########
if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
unlink "$counter_dir/$data[$db_key_pos]"; #### remove counter file
}
}
}
else { $output .= $line . "\n";
}
########## end multiple file upload lines
But I got a error on it.
I know I did something wrong, but I can't see it.
Thank you for your help.
Ed
Mod based on a script created by Jeff Carnahan jeffc@terminalp.com Adapted for use by DBMan by JPDeni deni@jpdeni.com Integration with DBMan script by Jim Kangosjärvi Jim.Kangosjarvi@Abc.se
If I delete a record that has A photo with it. the mod works fine.
But if I delete a record that dose not have a photo with it I get a error.
I tried a few things to see if it would work, and this what I came up with.
In my "sub delete_records" if I put this --
$delete_list{$data[$db_key_pos]} ? #
($delete_list{$data[$db_key_pos]} = 0) : #
($output .= $line . "\n");
The record would delete, but the photo would stay on the server.
If I replace it with this --
if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
}
}
else { $output .= $line . "\n"; }
It will delete a record that has A photo with it.
But if I delete a record that dose not have a photo with it I get a error.
I also tried this fix I found on this site from LoisC
######### changed for file upload mod ###########
if ($delete_list{$data[$db_key_pos]}) { # if this id is one we want to delete
$delete_list{$data[$db_key_pos]} = 0; # then mark it deleted and don't print it to the new database.
if ($db_upload) {
if (-e "$SAVE_DIRECTORY/$data[$db_key_pos]") {
opendir (GRAPHIC, "$SAVE_DIRECTORY/$data[$db_key_pos]") or &cgierr("unable to open directory in delete records: $SAVE_DIRECTORY/$data[$db_key_pos]. Reason: $!");
@files = readdir(GRAPHIC);
closedir (GRAPHIC);
foreach $file (@files) {
unlink ("$SAVE_DIRECTORY/$data[$db_key_pos]/$file");
}
rmdir "$SAVE_DIRECTORY/$data[$db_key_pos]";
unlink "$counter_dir/$data[$db_key_pos]"; #### remove counter file
}
}
}
else { $output .= $line . "\n";
}
########## end multiple file upload lines
But I got a error on it.
I know I did something wrong, but I can't see it.
Thank you for your help.
Ed