Jump to content

Fwrite


es131245
 Share

Recommended Posts

i got a counter that saves vars in txt file.txt file has 4 lines and each line is for different var but it always act differently when saving to txtive tryed fputs and fwrite but no useive tryed fputs($counter_open,"$counter_utd $counter_utl $counter_gtd $counter_gtl");fputs($counter_open,"$ounter_utd\n$counter_utl\n$counter_gtd\n$counter_gtl');fputs($counter_open,$counter_utd.$counter_utl.$counter_gtd.$counter_gtl);fputs($counter_open,$counter_utd."\n".$counter_utl."\n".$counter_gtd."\n".$counter_gtl."\n");Counter code$counter_open=fopen($counter,"r") or die($counter_open_die);$counter_date=date("j/n/Y",fileatime($counter));$counter_utd=fgets($counter_open,1024); $counter_utl=fgets($counter_open,1024);$counter_gtd=fgets($counter_open,1024); $counter_gtl=fgets($counter_open,1024);fclose($counter_open);if ($counter_date!=$date_date) {$counter_utd=0; $counter_gtd=0;}if ($_COOKIE["LastVisit"]!=$date_date){if ($user=="Гость" && $user=="Guest"){$counter_gtd=$counter_gtd+1;}else{$counter_utd=$counter_utd+1;}}$counter_open=fopen($counter,"w") or die($counter_open_die);fputs($counter_open,$counter_utd.$counter_utl.$counter_gtd.$counter_gtl);fclose($counter_open);<table class="counter" width="100%" cellpadding="0"style="border:1px solid green; border-style:solid; border-collapse:collapse;font-size:80%;"><tr><td></td><td align="center">Counter</td><td></td></tr><tr><td>Today</td><td></td><td>Total</td></tr><tr><td align="center"><? echo $counter_utd;?></td><td align="center">Users</td><td align="center"><? echo $counter_utl;?></td></tr><tr><td align="center"><? echo $counter_gtd;?></td><td align="center">Guests</td><td align="center"><? echo $counter_gtl;?></td></tr></table>counter looks like CounterToday Total 1 Users 1 1 Total 1 And txt file loooks like1 //$counter_utd Counter Users Today1 //$counter_utl Counter Users Total0 //$counter_gtd Counter Guests Today1 //$counter_gtl Counter Guests TotalBut i get for:1)fputs($counter_open,"$counter_utd $counter_utl $counter_gtd $counter_gtl");TXT:1 1 0 1Every page update leads to more spaces between last 3 digits2)fputs($counter_open,"$ounter_utd\n$counter_utl\n$counter_gtd\n$counter_gtl');same as fputs($counter_open,$counter_utd."\n".$counter_utl."\n".$counter_gtd."\n".$counter_gtl."\n");TXT:11013)Some times works like i wanted but sometimes i get 4 digits in one row in....fputs($counter_open,$counter_utd.$counter_utl.$counter_gtd.$counter_gtl);I had an idea with one row txt like$counter_utd=fgets($counter_open,1); $counter_utl=fgets($counter_open,1);$counter_gtd=fgets($counter_open,1); $counter_gtl=fgets($counter_open,1);fputs($counter_open,$counter_utd.$counter_utl.$counter_gtd.$counter_gtl);But 1 bit digits is usefull only then amount of visitors will fit in 1 bit [0-9]Any suggestions???

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...