Image Issue

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tito85
Forum Contributor
Posts: 104
Joined: Sat Mar 13, 2010 11:26 am

Image Issue

Post 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
  }
?>
User avatar
phdatabase
Forum Commoner
Posts: 83
Joined: Fri May 28, 2010 10:02 am
Location: Fort Myers, FL

Re: Image Issue

Post by phdatabase »

$filename is a result not a string.
tito85
Forum Contributor
Posts: 104
Joined: Sat Mar 13, 2010 11:26 am

Re: Image Issue

Post by tito85 »

Thanks Problem Solved.
Post Reply