FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


count script





rockkornman
well hello every one i have a small probleme with this script that save nothing in my file compteur.txt


Code:
<?php
$monfichier=fopen("compteur.txt","r+");
$ligne=fgets($monfichier);
$ligne++;
fseek($monfichier,0);
fputs($monfichierr,"$ligne");
fclose($monfichier);
?>
rvec
try this:
Code:
<?php
$monfichier=fopen("compteur.txt","r+");
if (filesize("compteur.txt")>0)
{
   $ligne=fread($monfichier, filesize("compteur.txt"));
   $ligne++;
} else
{
   $ligne = 1;
}

fseek($monfichier,0);
fputs($monfichier,"$ligne");
fclose($monfichier);
?>


you typed "monfichierr" instead of "monfichier" once and $ligne++ would cause a "undefined variable" notice if you have an empty file.

Maybe you'd also want to check if the file exists and if you have enough rights before reading and writing to it.
Related topics
script backup database
Count script or something else...
I need a VERY simple php script
Enter your webpage in this form to KNOW your keywords
Need a script
Give me a special countdown script for 10frih$
my PHP code benchmark script that got some problems
script show off- simplecron(tmp name, might change)
PHP script problem
Activation Script
Special Count Down Script
count input fields
PHP count current users
where do i put the statcounter script in a phpbb2 forum?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

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