while循环删除查询错误

时间:2013-08-18 14:31:25

标签: php mysql while-loop unlink

我使用下面的代码删除具有特定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");
}

0 个答案:

没有答案