Have your own tutorial made for you, just fill out the form below!!








View request list!
The IBox is having technical difficulties
 


Simple Counter

This is a really 2 file way of making a unique hit counter.

if you make a new file called counter.txt and just type the number 1 on the first line.

in a new file, paste the script

<?
$file = "counter.txt";
$fp= @fopen($file,"r+"); //this opens the file
$myCounter = (int)fgets($fp,10000); //
++$myCounter; //
rewind($fp);
fwrite($fp,$myCounter); //this will write the value
fclose($fp);
echo $myCounter; //this shows the value
?>

and save it as counter.php

then put in the script where you would like the counter to go!

<?
include("counter.php");
?>

make sure these are in the same folder on your FTP, and chmod the file counter.txt to 777

Example for this page:

Warning: fgets(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/counter.php on line 4

Warning: rewind(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/counter.php on line 6

Warning: fwrite(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/counter.php on line 7

Warning: fclose(): supplied argument is not a valid stream resource in /home/stealth/public_html/php/counter.php on line 8
1

STUCK ON CHMODDING? CLICK HERE



 
Latest Tutorial
Featured Site
[ Pimp-my-myspace]
Layout: 10/10
Content: 10/10
Stealth Statistics
Users Online
Staff
1
Photoshop Tutorials
61
PHP Tutorials
9
Affiliates
35
[ More Statistics ]