I'm trying to develop a script that will increment by one integer each time the script is called. So basically - if someone clicks the button/form that the script is attached to; it will increment that variable by one integer. The difficult part I'm having is saving that variable total each night at midnight - and then wiping the variable clean; so it starts at zero for the next day. I'd like to save that previous number too. Any thoughts?
If you had an earlier bug that wrote something invalid to your file, then adding 1 to that invalid value will just produce another invalid value. Try deleting the file and letting your script create it afresh. As far as the midnight roll up is concerned, if it is important that it be done right at midnight then you will need a cron job. Otherwise, you could add a comma and a timestamp to your file and check the timestamp every time you increment the counter. If the date has changed by one day, then you report the old number somewhere and start again from 1. cheers j