• I am very new to WP. I created the website and installed PHP Everywhere so I could add some of my own code. I created a simple table in MySQL using phpMyAdmin just to hold a hit counter. I added php code to connect and access and update the table.

    It seems to work correctly if I am logged in to WP and viewing the page–but works differently if not logged in (in which case it appears to read an old record from cache and displays incorrect count). The SQL code is:

    // select from MySQL to get hit count
    $sql = “SELECT SQL_NO_CACHE * FROM HitCount WHERE ID = ‘AGC’; “;

    Any suggestions?
    Thanks, Al

    • This topic was modified 5 years, 7 months ago by almageccom.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s common for caching schemes to not cache requests from logged in admin users while delivering cached data for everyone else. If you don’t have a caching plugin running, your host probably is. Caching is generally a good thing, but contrary to hit counters.

    To work around caching schemes, the hit counter value should be populated via Ajax request.

Viewing 1 replies (of 1 total)
  • The topic ‘MySQL different result when not logged in to WP’ is closed to new replies.