michAmir
michAmir

Reputation: 375

update set where with sql in php

if (!empty($prijs)) {

    $sql = "UPDATE producten 
    SET prijs='$prijs', 
    WHERE product_id='$product_id'";

    $query = $dbh->prepare( $sql );
    $result = $query->execute();
    If ($result){
        print "Product aangepast!";
            }
  }
}

Whenever I try to update the database nothing happens. I added the print statement to confirm that the database was updated but it doesnt appear. Is there anything wrong with my sql code or maybe the part where the sql code gets executed?

Upvotes: 1

Views: 257

Answers (1)

GrahamTheDev
GrahamTheDev

Reputation: 24865

$sql = "UPDATE producten 
SET prijs='$prijs' 
WHERE product_id='$product_id'";

I removed the comma after '$prijs' see if that helps

Upvotes: 1

Related Questions