Strange behavior of MySQL UPDATE query in PHP?

Posted by Prashant on Stack Overflow See other posts from Stack Overflow or by Prashant
Published on 2010-03-18T17:14:09Z Indexed on 2010/03/18 17:21 UTC
Read the original article Hit count: 264

Filed under:
|
|

When I am executing following query then its not updating views column by 1 instead sometimes its updating it by 2 or 3. Say currently views count is 24 then after executing this query it becomes 26 or sometimes its 27.

$views = $views + 1;
$_SQL = '';
$_SQL = 'UPDATE videos SET views = '.$views.' WHERE VideoId= "'.$videoid.'";';
@mysql_query($_SQL);

I am not getting why this is happening, am I missing something or the query is executing 2 times automatically? Please help me to figure out the issue.

Thanks

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php