Jump to content

Unlink : Permission denied


upendra470

Recommended Posts

I want to delete an image file from a folder using unlink. The code is :

$movie_id  = $checkbox[$i];

		 $sql = "DELETE from movie_basic_details where `movie_id` = '$movie_id'";
		 $result = mysql_query($sql) or die(mysql_error());
		 $sql1 = "DELETE from movie_details where `movie_id` = '$movie_id'";
		 $result = mysql_query($sql1) or die(mysql_error());
		 $sql2 = "DELETE from movie_stars where `movie_id` = '$movie_id'";
		 $result	= mysql_query($sql2) or die(mysql_error());
		 $query = "select movie_name from movie_basic_details where movie_id = '$movie_id'";
		 $res = mysql_query($query) or die(mysql_error());
		 $data = mysql_fetch_array($res);
		 unlink("upload/movies/".$data['movie_name']);

	 }

The entries in the database have been deleted but only the image corresponds to that entry do not get deleted. The following warning comes up :

 

Warning: unlink(upload/movies/) [function.unlink]: Permission denied in C:\wamp\www\ContentPanel\deletemovies.php on line 23

 

I have uploaded the files using $_FILES server variable and move_uploaded_file function. I am running this script on windows 7.

Please Help.

 

Link to comment
https://forums.phpfreaks.com/topic/246113-unlink-permission-denied/
Share on other sites

Warning: unlink(upload/movies/  )

 

$data['movie_name'] is empty ^^^^ (there's no file name in the error message showing what unlink was trying to do), because you have already deleted the row from your table in the first DELETE query and the last SELECT query returns zero rows.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.