Why won't the image from directory get deleted?
The rest working fine but just the image is not getting unlinked.
Here is my php code:
if(isset($_POST['delbtn'])){
$code = $_POST['delete'];
$stmt = $db->prepare("SELECT * FROM interviews WHERE reference = :reference");
$stmt->bindParam(':reference', $code, PDO::PARAM_STR);
$stmt->execute();
$cnt = $stmt->rowCount();
if($cnt!='0'){
$query = "delete from interviews where id IN(".$_GET['coach'].")";
$stmt = $db->prepare($query);
$stmt->execute();
while($rw = $stmt->fetch())
{
$file='uploads/interviews/'.$rw['image'];
@unlink($file);
}
echo "<script type='text/javascript'>
alert('Entry successfully deleted.');
window.location.href = 'need-help-with-interview.php';
</script>";
exit;
}else{
echo "<script type='text/javascript'>
alert('You are not authorized to delete this entry.');
window.location.href = 'need-help-with-interview.php';
</script>";
exit;
}
}