Using variables in MySQL UPDATE (PHP/MySQL) -


i using code can update record in database:

$query = mysql_query("update article                           set com_count = ". $comments_count                         article_id = .$art_id "); 

my question is: how can use variables in mysql update statement.

$query = mysql_query("update article set com_count = $comments_count article_id = $art_id");

you messing quotes , concats.

you can use inline vars previous example or concat them like:

$query = mysql_query("update article set com_count = " . $comments_count . " article_id = " . $art_id);


Comments