gmaestro
gmaestro

Reputation: 339

Simple DELETE php pdo query

I want to delete data but with multiple condition so I write this:

$STH = $DBH->prepare("DELETE FROM track_aktivnosti WHERE (ID,ajdi), VALUES(:id,:ajdi)");

            $STH->bindParam(':id', $_POST['vrednostid']);
        $STH->bindParam(':ajdi', $_POST['ajdi']);

but I have error is statement? What do I need to change?

Upvotes: 0

Views: 59

Answers (2)

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

$stmt = $dbh->prepare("DELETE FROM track_aktivnosti WHERE (ID = ? and ajdi = ?)");
$stmt->execute(array($_POST['vrednostid'],$_POST['ajdi']));

Upvotes: 1

echolocation
echolocation

Reputation: 1120

your SQL syntax is wrong. It should be

$STH = $DBH->prepare("DELETE FROM track_aktivnosti WHERE ID=:id AND ajdi=:ajdi");
$STH->bindParam(':id', $_POST['vrednostid']);
$STH->bindParam(':ajdi', $_POST['ajdi']);
$STH->execute();

Upvotes: 3

Related Questions