Jump to content

Mysql Counter Problem, it goes up in 2's!


teammist

Recommended Posts

 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?

Link to comment
https://forums.phpfreaks.com/topic/275555-mysql-counter-problem-it-goes-up-in-2s/
Share on other sites

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.