I want to increase by 1 a column in MySql table when the page is loaded, but the problem is that the value is increasing by 2 Here is my code that i put it od the page mysql_query("UPDATE game SET hits=hits+1 WHERE id='".$game_id."'") or die (mysql_error()); Any solution?????? And now i have noticed, it is only doing in Firefox, it works fine in IE
<?php $game_id=$HTTP_GET_VARS['game']; mysql_query("UPDATE game SET hits=hits+0.5 WHERE id='".$game_id."'") or die (mysql_error()); include('_drawrating.php'); $sql = mysql_query('SELECT * FROM game where id='.$game_id.''); $row=mysql_fetch_array($sql); /*,hhits=hhits+1,whits=whits+1,thits=thits+1*/ ?> <head> <script type="text/javascript" language="javascript" src="js/behavior.js"></script> <script type="text/javascript" language="javascript" src="js/rating.js"></script> </head> <link href="../css/rating.css" rel="stylesheet" type="text/css"> <script type="text/JavaScript"> <!-- function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> <body> <table width="670" height="360" border="0" cellpadding="0" cellspacing="0" class="catpaddinggame playborder"> <tr> <td width="238" height="25" align="left" valign="middle" bgcolor="#FFCC00" class="namegame"> <?php echo($row['name']); ?> </td> ......................... and continue It is very long to paste all
hard to say what the problem is since you arent showing all your code for it...is this file being included by another?
Well then it seems like this file is included more than once, which is why you get the double entry for it. check that you dont reference it twice
You can easily debug with this little trick: Save your query as a variable and echo the value of the variable on the screen, in the debugging stage. For instance, split: mysql_query("UPDATE game SET hits=hits+1 WHERE id='".$game_id."'") into: $query = "UPDATE game SET hits=hits+1 WHERE id='".$game_id."'"; $result = mysql_query ($query) Also, run a search, using your favorite text editor, to find all occurrences of mysql_query in your file and do the above for all mysql_query that you have in the script you wish to debug.
You may be running that script twice, so you need to have a look at your code, looking if the script is included twice in a file or something like that.
well i also suffered from same problem in one of my site that was updating the field when i was aking for +1 and it was updating randomly sometime 2 5 or 10 but that problem was solved auto i do not know how i guess there is the problem of data type conversion in the php plz try to make explicit data tye like for integers (integers) and for string (string) before passing to the my sql query soryy for my bad english