0

以下のコードを使用して特定の albumId を持つ画像を削除していますが、 $row_getPicturesToBeDeleted['imageName'] がループ内で空の結果を返すため、削除は機能しません。

  // Get picture file names to be deleted
  $colname_getPicturesToBeDeleted = "-1";
  if (isset($_GET['id'])) {
    $colname_getPicturesToBeDeleted = $_GET['id'];
  }
  mysql_select_db($database_eAlbum, $eAlbum);
  $query_getPicturesToBeDeleted = sprintf("SELECT * FROM pictures WHERE albumId = %s", 
  GetSQLValueString($colname_getPicturesToBeDeleted, "int"));
  $getPicturesToBeDeleted = mysql_query($query_getPicturesToBeDeleted, $eAlbum) or die(mysql_error());
  $row_getPicturesToBeDeleted = mysql_fetch_assoc($getPicturesToBeDeleted);
  $totalRows_getPicturesToBeDeleted = mysql_num_rows($getPicturesToBeDeleted);

  // Delete pictures also physically
  $dir = dirname(dirname(__FILE__));

  do {
    $imgToBeDeletedThumb = $dir."/server/php/files/thumbnail/".$row_getPicturesToBeDeleted['imageName'];
    $imgToBeDeleted = $dir."/server/php/files/".$row_getPicturesToBeDeleted['imageName'];
    unlink($imgToBeDeletedThumb);
    unlink($imgToBeDeleted);
  } while ($row_getPicturesToBeDeleted = mysql_fetch_assoc($getPicturesToBeDeleted));

  header("listAlbums.php?d=s");
}
4

0 に答える 0