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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.