moret Posted September 1, 2006 Share Posted September 1, 2006 Hi all,I'm doing a forum, and I have a table field named 'hits'. I want to increment one the value of this field each time a user visits a topic. It seems easy, but when page executes:[code]$result=mysql_query("UPDATE forum_messages SET hits=hits+1 WHERE id='$id");[/code]MySQL increments 2 instead 1, why?Thanks. Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 1, 2006 Share Posted September 1, 2006 for pure semantics change your query to:[code]<?php$result=mysql_query("UPDATE `forum_messages` SET `hits` = `hits` + 1 WHERE `id` ='$id'");?>[/code](also note you were missing a closing apostrophe after $id)now check that you don't run the query twice in the process of your application logic. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.