The Daily Static
  The Daily Static
UF Archives
Register
UF Membership
Ad Free Site
Postcards
Community

Geekfinder
UFie Gear
Advertise on UF

Forum Rules
& FAQ


Username

Password


Create a New Account

 
 

Back to UserFriendly Strip Comments Index

PHP Counter Script... by richlondoner2005-02-14 05:28:31
  Got it working - woohoo... by richlondoner 2005-02-14 07:09:34
Did it slightly different...

In the main file (default/personal/etc) I just set the variable up:

<?
$FileName = "default"
?>

Then in the include file (tail.php) I included the following where I wanted the counter to display:

<?
$file = "counter-" . $FileName . ".txt";//file containing hit count
$open = fopen($file, "r");
$hits = filesize($file);
$counter = fread($open, $hits);
fclose($open);
$open = fopen($file, "w");
++$counter;//adds 1 to ammount and displays it, to display before adding amount, change to $counter++
fwrite($open, $counter);
fclose($open);
echo $counter;
?>

and it seems to work perfectly, got two counters working independently of each other... Only recording another 6 counters so it easy from here in!

Thanks for peoples help, much appreciated!
Rich
[ Reply ]

 

[Todays Cartoon Discussion] [News Index]

Come get yer ARS (Account Registration System) Source Code here!
All images, characters, content and text are copyrighted and trademarks of J.D. Frazer except where other ownership applies. Don't do bad things, we have lawyers.
UserFriendly.Org and its operators are not liable for comments or content posted by its visitors, and will cheerfully assist the lawful authorities in hunting down script-kiddies, spammers and other net scum. And if you're really bad, we'll call your mom. (We're not kidding, we've done it before.)