stoodder
03-15-2003, 08:54 AM
okay you huys first i will give youthe code to analyze and then i will break it down into peices for oyu okay???
<?php
$filename = "hits.txt";
$fdata = fopen($filename, "r") or die ('Counter Error');
$fstring = fread($fdata, filesize($filename));
echo"$fstring";
fclose($fdata);
$fdata = fopen($filename, "w") or die ('Counter Error');
$fcounter = $fstring + 1;
$fend = fwrite($fd, $fcount);
fclose($fd);
?>
okay ill start by giving little definitions
$filename this is the exact fiole name of the file preferabbly .txt to write the counter surrent info to.
fopen fopen is a functiuon that goes and opens a file for later use in the script, the "r" stands for read it is going to read the file that it had just opend
fread mans that after the file is open it can read something within that file to get ready to display. in this case we are looking at the filesize of $filename
echo"$fstring"; this is what displays the counter... go ahead fiddle with it just make sure that iut has echo"$fstring OTHER TEXT HERE";
fclose this closes the current file notifying thet fread that that session it sone with the file
fopen with a "w" the "W" in this case stands for write, it is going to right the file when it is told to his means.
$fcounter this is the actually counter itsself.. this is what adds oin the number 1 to $fstring
$fend $fend is what finally sums up the proccess so that it writes to the file the current number plus on
then we do one mor efclose and you should bbe done! pretty easy? please email me if it isnt...stoodder@lycos.co.uk
<?php
$filename = "hits.txt";
$fdata = fopen($filename, "r") or die ('Counter Error');
$fstring = fread($fdata, filesize($filename));
echo"$fstring";
fclose($fdata);
$fdata = fopen($filename, "w") or die ('Counter Error');
$fcounter = $fstring + 1;
$fend = fwrite($fd, $fcount);
fclose($fd);
?>
okay ill start by giving little definitions
$filename this is the exact fiole name of the file preferabbly .txt to write the counter surrent info to.
fopen fopen is a functiuon that goes and opens a file for later use in the script, the "r" stands for read it is going to read the file that it had just opend
fread mans that after the file is open it can read something within that file to get ready to display. in this case we are looking at the filesize of $filename
echo"$fstring"; this is what displays the counter... go ahead fiddle with it just make sure that iut has echo"$fstring OTHER TEXT HERE";
fclose this closes the current file notifying thet fread that that session it sone with the file
fopen with a "w" the "W" in this case stands for write, it is going to right the file when it is told to his means.
$fcounter this is the actually counter itsself.. this is what adds oin the number 1 to $fstring
$fend $fend is what finally sums up the proccess so that it writes to the file the current number plus on
then we do one mor efclose and you should bbe done! pretty easy? please email me if it isnt...stoodder@lycos.co.uk