/    Sign up×
Community /Pin to ProfileBookmark

delete photo from folder with unlink

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: ” ;
}

}
}
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogFeb 11.2017 — You can fix it by adding the missing semi-colon at the end of the preceding line.
×

Success!

Help @wesley5 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...