I am using this code to delete a movie from the database. However I want that if a movie has an image named NoMovie.jpg, the image will not be deleted from the "Images/Movies/ Folder.
I need help because this is not working an the image is being deleted.
Code: Select all
<?php
session_start();
require('dbconnect.php');
include('securitycheck.php');
if ($isAdmin) {
$select = "SELECT Filename FROM movies WHERE MovieID = '" . $_GET['id'] . "'";
$filename = mysql_query($select);
if (strlen(mysql_result($filename, 0, 'Filename')) > 0 && $filename != "NoImage.jpg") {
unlink("Images/Movies/" . mysql_result($filename, 0, 'Filename'));
}
$delete = "DELETE FROM movies WHERE MovieID = '" . $_GET['id'] . "'";
mysql_query($delete) or die(mysql_error());
header('Location: movies.php');
} else {
?>
<center><b>You do not have permission to access this particular page.</b></center>
<?php
}
?>