Reputation: 1
I've been at this for a while now, and i'm having some trouble with my sql. Recently i've learned a bit about prepared statements and i've been using them untill this without any trouble. However now i'm having the issue that i'm not getting errors when i manually transfer the coded query into phpmyadmin, but when i excecute the code from the server it's not updating any records whatsoever.
excecuted code:
$stmt = $conn->prepare("UPDATE `diensten` SET `titel` = ':titel', `content` = ':beschrijving', `img` = ':img' WHERE `diensten`.`id` = ':id'");
$stmt->execute(array(':title' => $titel, ':beschrijving' => $beschrijving, ':img' => $img, ':id' => $id));
excuse the dutch in the code although it shouldn't obstruct any functionality.
Upvotes: 0
Views: 56
Reputation: 1269623
When you use prepared statements, you do not need single quotes around the values. The type is handled by the parameter insertion. So, you simply need:
$stmt = $conn->prepare("
UPDATE `diensten`
SET `titel` = :titel,
`content` = :beschrijving,
`img` = :img
WHERE `diensten`.`id` = :id");
(I put this on multiple lines for readability.)
Upvotes: 2