2009-10-03, 11:19 PM
I'm having trouble getting my script to remove a few files. If it weren't for the fact that the file locations are stored in the db, this would work.
1) It goes back to the listing and not doing anything
2) It shows a blank area where it should output the success of file deletion or failed deletion.
Any ideas to get this to work?
$fid = $_GET['fid'];
if($_GET['do'] == "d"){
echo "Are you sure you want to delete the download? This will also delete the file and preview. This can not be undone.<br>
<br>
<br>";
echo '<a href="admin.php?p=df&do=dele&fid='.$_GET['fid'].'">Yes, remove the download</a> <a href="admin.php?p=df">No, go back</a>';
if($_GET['do'] == "dele") {
$sql = mysql_query("SELECT * FROM $fileinfotable WHERE fid = $fid");
while($mem == mysql_fetch_array($sql)){
$file = $mem['filelink'];
$preview = $mem['previewlink'];
if(file_exists($file)){
unlink($mem['filelink']) or die("Unable to delete file.");
print "File deleted.<br />";
if(file_exists($preview)){
unlink($mem['previewlink']) or die("Unable to delete preview file.");
print "Preview deleted.<br />";
mysql_query("DELETE FROM `$fileinfotable` WHERE `fid` = '$fid' LIMIT 1") or die("Deletion failed.<br><BR><BR>Go back and try again");
echo "Entry Deleted. <a href=admin.php?p=df>Go back.</a>";}
else{print "Preview does not exist.";}}
else{print "File does not exist.";}}
}
}
else{$msel = mysql_query("SELECT * FROM $fileinfotable ORDER BY `fid` ASC");
while ($mem = mysql_fetch_array($msel)) {
print "<a href='admin.php?p=df&do=d&fid=".$mem['fid']."'> ".$mem['filename']."</a><br> ";
}}
It lists the files just file, the warning works, it gets to the page where it should run the queries, and one of two things happen.1) It goes back to the listing and not doing anything
2) It shows a blank area where it should output the success of file deletion or failed deletion.
Any ideas to get this to work?