I have a variable $id
which gives me the id
of the current article and this can help me to make an update query in my database on current article.
This is my code:
$vizualizari = $current_views+1; $sql1= "UPDATE detalii_cantari SET viz = viz WHERE id = {$id};"; $q1 = $dbh->prepare($sql1); $q1->execute(array(':viz'=>$vizualizari));
I don’t get any errors but my code is still not working…
Advertisement
Answer
Your correct code is here:
$vizualizari = $current_views+1; $sql1= "UPDATE detalii_cantari SET viz = :viz WHERE id = {$id}"; $q1 = $dbh->prepare($sql1); $q1->execute(array(':viz'=>$vizualizari));
;
from the end of sql is not needed here and viz = viz
must become viz = :viz
because of PDO.