in reply to DB Ovewriting (again..)/ Counter Question

Your first script works fine, if you were checking the result of the tie, you would probably find that there is some sort of error opening the dbm file (probably permissions, since it's a CGI script, the user the cgi runs as probably doesn't have permission to write to the directory you are asking it to create the database in).

For the second part, I would store a count of the hits for each day associated with their dates, that way you actually only store one count for each day, so when you want your script to display $hitstoday, you just display the counter for that day, when you want $weekhits, you add up the last 7 days of hits in your database and display that, and if you want $totalhits, you add up the counters for all the dates.


We're not surrounded, we're in a target-rich environment!
  • Comment on Re: DB Ovewriting (again..)/ Counter Question

Replies are listed 'Best First'.
Re: Re: DB Ovewriting (again..)/ Counter Question
by sulfericacid (Deacon) on Apr 06, 2003 at 06:37 UTC
    Ok, you figured out what the error was. I am so frustrated because it was a simple thing like 'the database isn't being made'. I was nearly sure it was (though I should have checked) because my or die(warn..) never mentioned anything.

    As for the counter script would I have to do something which will calculate hours into days into a week so the script can work with it?

    Thanks for your help!

    "Age is nothing more than an inaccurate number bestowed upon us at birth as just another means for others to judge and classify us"

    sulfericacid

      As for the counter script would I have to do something which will calculate hours into days into a week so the script can work with it?

      I would just store it along with the current date, if storing it in a dbm, you could just do $counters{$date}++;. That way you get a dbm with dates for keys, and counts for value. To get a count for the week, just figure out which 7 days make up the week you want data for (using Date::Calc or something similar would make it easy), then add up the counters for those 7 days. To get a total count, add up all the values.


      We're not surrounded, we're in a target-rich environment!