Hi everyone,
I have been searching the forums for examples of using unlink() and I thought I understood it, but my code is not working.
I have a form where the user can upload an image. The image is stored in a directory on my server and the path to that file is stored in a database. I have have another form that allows an admin to delete that row from the database, but I also want the actual image file deleted too.
I don't recieve any errors, but the rows get deleted from the database and images do not get deleted. I am using PHP5, MySQL and PEAR. Does anyone have any thoughts on why this is not working?
Thanks in advance!
Here is my code:
if($_SERVER['REQUEST_METHOD']=='POST') {
if ($_POST['yes_no'] == 'yes') {
$isbn = $_POST['isbn'];
$sql_select = "SELECT image FROM lounge WHERE isbn = $isbn";
$rows = $db->getRow($sql_select);
$uploaddir = "uploads/";
$filename = $rows[image];
$image = $uploaddir.$filename;
unlink($image);
$sql_delete = "DELETE FROM lounge WHERE isbn = $isbn";
$db->query($sql_delete);
print "<script>window.location='water_music_retrieve_testing.php'</script>";
} else {
print "Record not deleted";
print "<script>window.location='water_music_retrieve_testing.php'</script>";
}
}