Page 1 of 1

Image Issue

Posted: Sat May 29, 2010 3:14 pm
by tito85
Hi,

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
  }
?>

Re: Image Issue

Posted: Sat May 29, 2010 3:22 pm
by phdatabase
$filename is a result not a string.

Re: Image Issue

Posted: Sat May 29, 2010 3:37 pm
by tito85
Thanks Problem Solved.