FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

counter

 


AlexandruDan
Hello.
I have a question: how can I make this script to work?
The problem is that when I create the contor.txt file, it is emplty and I receve an error. If I manually add a value in it, it works just fine...

Here's the script:

<?php
$deschide = fopen("contor.txt",r);
$valoare = fread($deschide,filesize("contor.txt"));
$valoare++;
fclose($deschide);
if ($_COOKIE["vizitat"]!="da"){
$deschide = fopen("contor.txt",w);
fwrite($deschide, $valoare);
setcookie("vizitat","da",time()+2);
fclose($deschide);
}
else {
echo "<br /> deja ai accesat pagina o data in ultimele 5 secunde <br />";
}
echo "fisierul a fost deschis de $valoare ori";
?>
Diablosblizz
In contor.txt you can't have a blank value. For your script, it NEEDS to be a number (like 0). I believe if you do this then it will set the blank value to 0.

Code:
<?php
$deschide=fopen("contor.txt",r);
$check=fread($deschide);
if($check == "") {
$number=0;
$valoare=fwrite($deschide,$number);
}
?>
manav
please make sure tht counter.txt is chmod to 777 that is read write and executable permissions are set correctly for it....
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.