perkins_dp Posted September 11, 2009 Share Posted September 11, 2009 I have a unique counter made on my new page, im just wondering if there is a way to have it start above 0 to show the hits from before i uploaded my new page. I have looked all over and cant seem to find a straight answer, perkins_dp Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/ Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 Can we see some code? Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916859 Share on other sites More sharing options...
perkins_dp Posted September 11, 2009 Author Share Posted September 11, 2009 im using this and using an include in my main file, <? $filename = "counter.txt"; $file = file($filename); $file = array_unique($file); $hits = count($file); echo $hits; $fd = fopen ($filename , "r"); $fstring = fread ($fd , filesize ($filename)); fclose($fd); $fd = fopen ($filename , "w"); $fcounted = $fstring."\n".getenv("REMOTE_ADDR"); $fout= fwrite ($fd , $fcounted ); fclose($fd); ?> Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916861 Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 So is your problem that you keep overwriting what's in the counter.txt file? So each time it starts with 0 + the 1 that would be the viewer? Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916866 Share on other sites More sharing options...
perkins_dp Posted September 11, 2009 Author Share Posted September 11, 2009 no no sorry if im not making much sense, the code works fine and increments by one for every unique hit, but I just put it on my new site and the hits started fresh at 0 where i had 13,500 on my older version of the site and im wondering if there is a way to make my new counter start at this number Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916867 Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 Couldnt you just place the counter.txt file from the old website into the new one and have the counter pick up from there? Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916875 Share on other sites More sharing options...
perkins_dp Posted September 11, 2009 Author Share Posted September 11, 2009 i wish i could, when last developed we used a counter script from a site and didnt have a counter.txt for the last, i thought there would be something to add in the code to tell it to start from a certain number but i cant seem to find anything Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916877 Share on other sites More sharing options...
iPixel Posted September 11, 2009 Share Posted September 11, 2009 What you use, basically in opens counter.txt and reads the amount of entries "IP's". I dont think you can script it to know it should be 13,500 more unless you do echo $hits + 13500; so essentially you start with 13500 as opposed to 0; or rather you simply tack on 13500 to your $hits. It's cheating but it would work. Link to comment https://forums.phpfreaks.com/topic/173927-unique-counter/#findComment-916887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.