adam291086 Posted October 5, 2007 Share Posted October 5, 2007 Hello I have some script that takes an album id and deletes that album and the specific photos in that album. The code does run. The problem is that an error message i set to echo appears saying error deleting photo once the page automatically refreshes. When i check the image folder the images actually have been deleted. Can anyone see whats happening <?php include("config.php"); // No album id has been selected if( !$_GET['album_id'] ){ $msg .= "Album not selected. Please choose an album you wish to delete!"; $msg .= "<br /><a href=\"edit_album.php\">Edit albums</a>"; displayPage($msg, "Error Selecting Album"); } else { $con; // Delete specified album $sql = "DELETE FROM albums WHERE album_id = " . addslashes($_GET['album_id']); $result = @mysql_query($sql) or die("Error deleting record: " . mysql_error()); // Retrieve image and thumbnail path information $sql = "SELECT photo_location, thumbnail_location FROM photos WHERE album_id = " . addslashes($_GET['album_id']); $result = @mysql_query($sql) or die("Error retrieving records: " . mysql_error()); while ($row = mysql_fetch_array($result)){ $photo_location = $row['photo_location']; $thumb_location = $row['thumbnail_location']; } if (@unlink("../adam/photos/" . $photo_location)){ } else { die("Error deleting photo!<br /><a href=\"index.html\">Please try again</a>."); } if (@unlink("../adam/thumbs/" . $thumb_location)){ } else { die("Error deleting thumbnail!<br /><a href=\"index.html\">Please try again</a>."); } // Delete specified photo $sql = "DELETE FROM photos WHERE album_id = " . addslashes($_GET['album_id']); $result = @mysql_query($sql) or die("Error deleting record: " . mysql_error()); // Display success to user $msg .= "Photos and album have been successfully deleted The page will now Refresh!<br />"; displayPage($msg, "Album and Photos Deleted!"); } ?> Link to comment https://forums.phpfreaks.com/topic/71947-solved-deleting-files/ Share on other sites More sharing options...
marcus Posted October 5, 2007 Share Posted October 5, 2007 Try giving a nice woohoo message. if(@unlink("../adam/photos/" . $photo_location)){ echo "DELETED!"; }else { die("Error"); } Anyways you should be doing the deleting inside the while loop. Link to comment https://forums.phpfreaks.com/topic/71947-solved-deleting-files/#findComment-362361 Share on other sites More sharing options...
adam291086 Posted October 5, 2007 Author Share Posted October 5, 2007 I changed the while loop but when the page refresh it stilll says error deleting photo but the photos are deleted. I also added in the echo but i get nothing. But the files are still being deleted from the folder Link to comment https://forums.phpfreaks.com/topic/71947-solved-deleting-files/#findComment-362366 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.