hello,
I have a function where photo can deleted from a folder with unlink. But I select first the row image (path to the image folder)and I get the error: Parse error: syntax error, unexpected ‘$name1’ (T_VARIABLE).
My question is: how can I fix this, so that delete the photo in the folder?
thanks in advance
class is:
[code=php]
class Photo{
public function DeleteFoto($id){
$id = $_GET[‘delete_id’];
$name = “SELECT * FROM foto WHERE id=$id”;
//$res = mysqli_query($this->database, $name);
$result = $this->database->query($name);
//$row = mysqli_fetch_assoc($res);
// $row->fetch_assoc($res);
$row = $result->fetch_assoc()
$name1 = $row[‘image’];
//print_r($name1);
if ($stmt = $this->database->prepare(“DELETE FROM foto WHERE id = ? LIMIT 1”))
{
echo “Bestand is verwijderd”;
$stmt->bind_param(“i”, $id);
$folder = ‘phpoopadministratie_systeemimages’;
chown($folder,777);
//var_dump($name1);
unlink($_SERVER[‘DOCUMENT_ROOT’] . “/php/oop/administratie_systeem/$name1”);
$stmt->execute();
$stmt->close();
}
else
{
echo ‘Specified file not found:’.$name1;
echo “Error deleting record: ” ;
}
}
}