This function is typically called from within a loop but apparently the presence of continue causes an issue even when not actually using the function. It works fine on my more forgiving live server but my local development system protests. How do I tell it to continue to the next line without using continue?
function deleteImage($ImageName, $UpdateID) {
$array = explode('.', $ImageName);
$ext = end($array);
if ($ext == "pdf") :
$fileTemplate = $_SERVER['DOCUMENT_ROOT'].
DIRECTORY_SEPARATOR . "folder1" .
DIRECTORY_SEPARATOR . "folder2" .
DIRECTORY_SEPARATOR . "%s";
else :
$fileTemplate = $_SERVER['DOCUMENT_ROOT'].
DIRECTORY_SEPARATOR . "folder1" .
DIRECTORY_SEPARATOR . "folder3" .
DIRECTORY_SEPARATOR . "%s";
endif;
if (isset($_POST['update'])):
if (!empty($_POST['CheckBox_Delete'][$UpdateID])) :
$sqlDelete = "DELETE FROM images WHERE ID=$UpdateID";
$sqlFolder = "SELECT EntryID FROM images WHERE ID=$UpdateID";
if (is_null($ImageName) || is_null($UpdateID)) continue;
if (empty($ImageName) || empty($UpdateID)) continue;
$fileName = sprintf($fileTemplate, $ImageName);
DBConnect($sqlDelete, "Delete", "pchome_cartrivision");
// Make sure the file is not in use elsewhere before deleting it from the server
$sqlOtherUse = "SELECT COUNT(ID) FROM images WHERE ImageName='$ImageName' AND ID <> $UpdateID";
$OtherUse = DBLookup($sqlOtherUse, "db_name");
if ($OtherUse < 1) :
@unlink($fileName);
AlertMessage("The file has been deleted!");
else:
AlertMessage("Removed from this entry but the file is in use elsewhere so cannot be deleted.");
endif;
endif;
endif;
}
Aucun commentaire:
Enregistrer un commentaire