1.0.3 Statistics working erratically

Discussion in 'General Support' started by Grinfeld, Jun 3, 2014.

  1. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    I am still having trouble with this for my 1.1.1 Webid version but, I do believe I have figured out what file writes the data to the database. It's the includes/stats.inc.php which there is an include for stats.inc.php page in the header.php.
    PHP:
    include $include_path 'stats.inc.php';
    Then I see this little query here around line 65 in the includes/stats.inc.php file.
    PHP:
    $query "INSERT INTO " $DBPrefix "currentaccesses VALUES (
    That should be where it starts to write to the database.

    My issue is that it's not writing to the database so, there is no way my Webid site get anything to SELECT FROM if there is no new report to show.

    The viewaccessstats.php does what it say, it views. It looks at the database and if there is nothing to report then it won't report anything. I already know it's not writing anything to report in the database so, I won't worry about this page until last.

    Any ideas why my currentaccesses in my database is not being written to? My last report was in 2014. I am looking at all of my back ups of my files to see if there was something there that I might of changed to have caused the problems. One thing I am curious about is maybe when I changed the gmdate() strings to (date) that it may have caused some problems.
     
  2. codenys

    codenys New Member

    Joined:
    Mar 3, 2014
    Messages:
    1
    Likes Received:
    0
    Hi! The problem it´s on line 60 in stats.inc.php, you need to add

    AND year = " . $THISYEAR;

    after

    month = " . $THISMONTH;

    So the correct line should be :

    $query = "SELECT day, month FROM " . $DBPrefix . "currentaccesses WHERE day = " . $THISDAY . " AND month = " . $THISMONTH . " AND year = " . $THISYEAR;
     
  3. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    @codenys Welcome to the webidsupport forum! Thanks for your reply and help! You've helped me to get it to work! Thank you very much!

    I totally forgot about the issue. I last posted that in May of 2016 and just put it off. I honestly thought the issue had been fixed when I updated my script but, I just checked and it was still not working. My coding has changed on my Webid script however since May of 2016 when I updated from 1.1.0 to 1.2.1 back in July of 2016. Now the coding is different. I made the changes thanks to you pointing out the $THISYEAR, I added the one line of code and updated the query to how you mentioned and it works. I will share both the SELECT and INSERT INTO query and the code below:

    PHP:
            $query "SELECT day, month FROM " $DBPrefix "currentaccesses WHERE day = " $THISDAY " AND month = " $THISMONTH " AND year = " $THISYEAR;
            
    $params = array();
            
    $params[] = array(':day'$THISDAY'int');
            
    $params[] = array(':month'$THISMONTH'str');
            
    $params[] = array(':year'$THISYEAR'int');
            
    $db->query($query$params);
            if (
    $db->numrows() == 0)
            {
                
    $query "INSERT INTO " $DBPrefix "currentaccesses VALUES (:day, :month, :year, 0, 0, 0)";
                
    $params = array();
                
    $params[] = array(':day'$THISDAY'int');
                
    $params[] = array(':month'$THISMONTH'str');
                
    $params[] = array(':year'$THISYEAR'int');
                
    $db->query($query$params);
            }
    I wouldn't of seen that without your help! Thanks! As soon as I added the code the Statistics went from showing nothing to showing me this.

    capture-20170820-222456.png

    The stat counter is live too now. When I surf onto the site, the blue counter goes up for each page I view. I thought it wouldn't show results until the end of the day. It's been so long since I have seen it work that I don't remember if it was a live counter or not. It's good now. I appreciate the help!!!
     
    Last edited: Aug 21, 2017
  4. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,165
    Likes Received:
    251
    It's so strange though that in the latest Github script that the Stats work without changing the code there.
     

Share This Page