Forum Moderators: coopster
$sql = 'SELECT COUNT(*) AS total FROM news_comments WHERE news_id = ' . $someVariable;
Is there any risk of 2 users adding comments so close together that this fails and only adds 1, when there are 2 new comments?if(submit button pressed / validation passed){
// Do comment insert
$sql = 'SELECT t_comments FROM news WHERE news_id = ' . $someVariable;
$res = mysql_query($sql);
$total = mysql_result($res, 0, "total_comments");
$total += 1;
$sql = 'UPDATE news SET t_comments = ' . $total . ' WHERE news_id = ' . $someVariable;
mysql_query($sql);
}