teammist Posted March 12, 2013 Share Posted March 12, 2013 mysql_connect("localhost", "lala", "password") or die(mysql_error()); mysql_select_db("blah") or die(mysql_error()); //Adds one to the counter mysql_query("UPDATE counter SET counter = counter + 1"); $count = mysql_fetch_row(mysql_query("SELECT counter FROM counter")); why does it go up in 2s? Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/ Share on other sites More sharing options...
kicken Posted March 12, 2013 Share Posted March 12, 2013 Most likely explanation: You're requesting the page twice. Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418210 Share on other sites More sharing options...
teammist Posted March 12, 2013 Author Share Posted March 12, 2013 well. Its this image. http://teammist.biz/image.php Not giving the code because i worked hard on it. It requests a few things, but yet, i tried it with a text file: $File = "counter.txt"; //This is the text file we keep our count in, that we just made $handle = fopen($File, 'r+') ; //Here we set the file, and the permissions to read plus write $data = fread($handle, 512) ; //Actully get the count from the file $count = $data + 1; //Add the new visitor to the count fseek($handle, 0) ; //Puts the pointer back to the begining of the file fwrite($handle, $count) ; //saves the new count to the file fclose($handle) ; //closes the file And had no problems. Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418213 Share on other sites More sharing options...
teammist Posted March 13, 2013 Author Share Posted March 13, 2013 bump... Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418355 Share on other sites More sharing options...
teammist Posted March 15, 2013 Author Share Posted March 15, 2013 Fucking hell... BUMOP Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418825 Share on other sites More sharing options...
Jessica Posted March 15, 2013 Share Posted March 15, 2013 You want us to help you but you won't post your code? What do you expect us to do, wave a magic wand? Something is causing the code to run twice, OR the problem is IN your code. Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418826 Share on other sites More sharing options...
Maq Posted March 15, 2013 Share Posted March 15, 2013 ^ Pretty much what jesi said. How is this being submitted? I would turn on a debugging tool that shows you network requests to see what's going on. Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418873 Share on other sites More sharing options...
Psycho Posted March 15, 2013 Share Posted March 15, 2013 Not giving the code because i worked hard on it. It requests a few things, but yet, i tried it with a text file: Really? I could write code to dynamically create an image with the same data in about 30 min. And, you work hard on something that you don't want to share, but expect US to take time out of our lives to help you for free. Interesting. Quote Link to comment https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/#findComment-1418891 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.