Joined: Feb 01, 2007 Posts: 9 Location: Australia baby!
Posted: Thu Mar 13, 2008 12:50 pm Post subject: counter.php has stopped inserting stats_date
Hey Evaders! I've just re-done my whole phpnuke setup with 7.8 patched and everything was looking completely perfect. I started with the full patched archive and modded everything back up again so my site looked just like how it used to be, in order to make sure all the code was gonna be ok and I didn't miss anything or mess it up.
I also updated from MySQL 4.1 to 5.0, and since then I have noticed when I look at my stats page, the counts for the day are not being added anymore :/
Has there been any change to the stats_date table in recent versions of patched? I know MySQL 5.0 has some data restrictions or some bs new "feature" that stops the data being added to the table unless it matches the correct format the column is expecting, and figure that's my problem but I'm not sure what the column types used to be compared to what they now are. You know like varchar, string etc.
It is currently adding the hourly stats to the database, but not the daily stats, so I have been manually adding up the hourly stats at the end of each day and adding the new row to the stats_date table. I haven't added todays manually, so you can see the 14th is missing from the stats screen. If you use the link to display hourly stats from the 13th and replace 13 with 14, you can see the hourly stats are there no worries.
Any idea how to fix this one up mate? Perhaps where to start debugging if you don't know off-hand? I know the code resides in includes/counter.php but that's about it! Any suggestions would be greatly appreciated mate.
I don't see anything offhand. If you want me to look into it, PM or email me access to your site (I don't run MySQL 5 so I can't replicate this easily) _________________ Evaders99 Webmaster Administrator Fighting is terrible, but not as terrible as losing the will to fight.
- SW:Rebellion Network - Evaders Squadron Coding -
Joined: Feb 01, 2007 Posts: 9 Location: Australia baby!
Posted: Sun Mar 16, 2008 2:38 am Post subject: would you be willing to help me craft a mysql query for it?
I don't have any ftp or other access available at the moment to get you to the files themselves, but I had an idea that someone with mysql command line knowledge like yourself could definately make use of to fix the problem.
The code in the counter.php that updates that stats_date table is:
$db->sql_query("UPDATE ".$prefix."_stats_date SET hits=hits+1 WHERE (year='$nowYear') AND (month='$nowMonth') AND (date='$nowDate')");
Can you possibly tell me how to make that line hits=sum(stats_hour) instead? Really phpnuke should probably only have to count up the hourly stats- everything else can be calculated from those instead of saying +1 and having its own seperate count. This could also stop any stats not matching up for previous dates, as I have manually added them up myself and may have made mistakes..
Any way you could help me out here with either that one line, or if you have the time/inclination maybe a code that will update all my dates by adding up that day's hourly hits? (just to be run once only)?
I think this still leaves me with the problem of the insert line not inserting for stats_date also, which is INSERT INTO ".$prefix."_stats_date VALUES ('$nowYear','$i','$k','0')"); - but I may be able to work that one out myself. I know I'm already asking a lot of you
Keeping two data records, for dates and hours, is actually more efficient. There is a specific entry to update when it does hits=hits+1
It does not have to do any reprocessing and further subqueries.
Updating at this point is rather pointless. Yes you could write a subquery and do hits=sum(stats_hour) ... but then you still have that as a separate data record. _________________ Evaders99 Webmaster Administrator Fighting is terrible, but not as terrible as losing the will to fight.
- SW:Rebellion Network - Evaders Squadron Coding -
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum