Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除查询错误的While循环_Php_Mysql_While Loop_Unlink - Fatal编程技术网

Php 删除查询错误的While循环

Php 删除查询错误的While循环,php,mysql,while-loop,unlink,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'];

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

尝试在循环之前转储
$row\u getPicturesToBeDeleted
,是否为空?谢谢!问题是,正如您所说,我首先从数据库中删除图像,然后尝试通过从数据库中获取文件名数据来物理删除图像,该数据自我删除后为空:)