我正在使用下面的代码删除具有特定专辑 ID 的图像,但删除不起作用,因为 $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");
}