| 4:44 pm on Mar 23, 2008 (gmt 0)|
It doesnt look like it should be doing.
There is a simpler way though - try this
mysql_query("UPDATE page SET views=(views+1)") or die(mysql_error());
This will update all page records in the table though - i dont know how your system is setup but you might want to specify which record you want to update eg.
mysql_query("UPDATE page SET views=(views+1) WHERE pageName = 'homepage'") or die(mysql_error());
Hope this helps
| 4:53 pm on Mar 23, 2008 (gmt 0)|
Thanks for your reply, the code is cleaner now, but it still adds two instead of one, I have no idea what I'm doing wrong!
| 1:31 pm on Mar 24, 2008 (gmt 0)|
Is this contained in a function or something? A loop perhaps? Print out the query right before you run it each time to see if you are calling it more than once during script execution.
| 2:16 pm on Mar 24, 2008 (gmt 0)|
Silly questions... Are you running any kind of browser plugin/toolbar that might cause an additional hit to any page you look at? Or does the page itself have any included code that might cause a robot to visit the page?
| 6:17 pm on Mar 24, 2008 (gmt 0)|
Are you including the page in another page? Do you capture the page in the output buffer? Either way, it looks like the page is being processed twice!?
| 5:27 pm on Mar 30, 2008 (gmt 0)|
Fixed it guys! :D
Because I'm using a URL request script to include files if the URL has a specific value added to it, the index page acts like this (for no apparent reason)
1) Process index page
2) Check for URL request
3) If URL request, Run Index page
4) If URL request, Run Index & Included pages
5) If no URL request, Run 404 page
I worked this out by telling the page to write to "INDEX_DUMP.LOG"
I used a custom log format, so I could understand the output
This is what I got;
// LANGUAGE: "Simplified Jargon"
//// AUTHOR: "Ryan (Noggin) Boylett"
/// VERSION: "3.0.1"
///// TITLE: "INDEX_DUMP.LOG"
== RUN INDEX PAGE
== PHP CODE INITIALIZED ENTITLED "?"
== PHP CODE IF STATEMENT
== PHP CODE IFTRUE REDIRECT PAGE TO \nINDEX
== PHP CODE IFTRUE PROCESS PAGE INDEX
== PHP CODE IFTRUE PROCESS PAGE INDEX&&'res/inc/home.php'
== PHP CODE IFFALSE PROCESS PAGE INDEX&&'res/inc/404.php'
So, I just added the MySQL code to every include page (which appears to only process once), and it works!