Jump to content

Recommended Posts

Recently got a PHP based script from a friend which I use on several of my sites to get the total visitors, total visits today and unique visits today. But the thing is that every day the script erases itself to 0 and its not supposed to happen. I'm not sure how to post the coding here and such but I can upload script to someone if they want to help me :)

 

A site which has the script, for example is www.uma-fan.com and you see it on the left menu at the bottom.

 

 

Never heard of phps but I guess you mean this ;)

 

http://www.uma-fan.com/rtoc.phps

thats the main code which is its own php file.

then the script uses a stats.txt and online.txt which you CHMOD to 777.

 

http://www.uma-fan.com/README.txt

this is the readme file

 

For some reason is there a index.php file in the zip I got but I dont think its neccesarry to use and its not possible to use that code because I can't overwrite my own index.php

http://www.uma-fan.com/index.phps

 

That should be it and thanks again! :)

 

 

From what I can see it's because you're using

 


$fp = fopen("./stats.txt","w"); 

 

the "w" is what's causing it to reset, because as it says in the manual

'w' - Open for writing only; place the file pointer at the beginning of the file and truncate the file to zero length. If the file does not exist, attempt to create it.

 

You want to use "a", which appends the file, so adds all the new data to the end of the existing instead of overwriting.

 


$fp = fopen("./stats.txt","a"); 

 

'a'  - Open for writing only; place the file pointer at the end of the file. If the file does not exist, attempt to create it.

Sam

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.