WordPress.org

Ready to get started?Download WordPress

Forums

Post Counter plugin database question (8 posts)

  1. macwise
    Member
    Posted 9 years ago #

    I am trying to install the visitor counter plugin, and need help getting the correct information in my mysql database. The plugin is here:
    http://weblogtoolscollection.com/b2-img/top10.zip

    I am trying to insert this snippet into a table, (however, I am not familiar with mysql very much at all):
    use <your_wpdatabase>;
    create table mostAccessed
    (
    postnumber int not null,
    cntaccess int not null,
    primary key(postnumber),
    unique id(postnumber)
    );

    As I mentioned, this poses a problem because I don't really know much about mysql...like, nothing. How can I create a new table in mysql in command line and insert this information? Any help is appreciated.

    Thanks

  2. Mark (podz)
    Support Maven
    Posted 9 years ago #

    Login to phpmyadmin
    Click the name of your database.
    Follow the first THREE images here:
    http://www.tamba2.org.uk/wordpress/backup/
    In that 3 screenshot, you can see an SQL tab
    In your phpmyadmin, click that tab.

    On the next screen is a white box.
    Into that, paste this

    create table mostAccessed
    (
    postnumber int not null,
    cntaccess int not null,
    primary key(postnumber),
    unique id(postnumber)
    );

    Then click Go.
    It will probably ask if you are sure, just say yes.

  3. Mark (podz)
    Support Maven
    Posted 9 years ago #

    http://www.tamba2.org.uk/wordpress/lastvisit/index.txt

    That file shows where I put the rest of the code to get it to work.

  4. macwise
    Member
    Posted 9 years ago #

    Thanks for the swift reply, podz. I guess I am deeper in this than I thought. I currently don't have phpmyadmin configured to see the tables for the wp database tables. I am not sure if I should get that setup, or if I should rather just do this from command line. If it isn't too much trouble, I would love to get the phpmyadmin up and running, but I am going to need a few pointers before I get it going, let alone the script. Thanks

  5. macwise
    Member
    Posted 9 years ago #

    btw, phpadmin comes back with this:

    Server localhost

    Error

    SQL-query :

    SET PASSWORD = PASSWORD( '**********' )

    MySQL said:

    #1044 - Access denied for user: '@localhost' to database 'mysql'

    It appears that permissions are not correct
    Any ideas on what permissions I need to change for phpmyadmin to function, while still keeping me safe?

  6. macwise
    Member
    Posted 9 years ago #

    Ok, I got the phpmyadmin figured out. I actually got the plugin working as well. However, it is activiated through the main index.php file, and therefore counts any visit to that page on any post that is there at the moment. I would like the script to count the index page once EACH TIME someone visits it, but I would also like the counter to ONLY count posts when they are visited at the posts URL. Is that completely unnecessary, or wrong, or is this a common thing to want a counter to do? Please let me know what I should expect out of this and any reasons why this may not be the best approach. Thanks.

  7. macwise
    Member
    Posted 9 years ago #

    Also, podz:

    http://www.tamba2.org.uk/wordpress/lastvisit/index.txt

    That file shows where I put the rest of the code to get it to work.

    I didn't quite understand this last post by you. I went there, and only found a graph and a few other lines of code. Should I be looking for something specific?

    Thanks

  8. macwise
    Member
    Posted 9 years ago #

    OK, let me start over. When I go to the index page of my WP site, the posts show up, and the visitor counts show up in the header bar for each post.

    The problem is that the numbers all correspond to eachother. The top post has the same number of views as the second post, and the third, and so on.

    When I visit a post by clicking on it's respective link, it takes me to that page, and it shows that there is another visit, but when I go back to the index page and refresh, it shows the number that the individual post had, only the other posts all have that new number as well.

    For instance:
    If I have 15 views showing on each post in the index page, and then click on the top post, it shows me the new post with the number of views elevated to 16. If I refresh that page, the number stays at 16. If I go back to the index page, however, and refresh it, then all of the posts now say 16 views. If I refresh again, then they all say 17 views, and so on.

    I am not sure what I am doing wrong, but I would obviously like each post to record independently how many views it has had. I am not sure it is such a bad thing to have the post views counted from the index page, but I KNOW that I do want the posts to be counted from that post being clicked on and viewed seperately. Please help.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.