WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Popularity Contest] Unable to activate in WordPress 3.0.2 (34 posts)

  1. microsleep
    Member
    Posted 3 years ago #

    Hello,

    I am running the latest version of WordPress (3.0.2) on a local server. I want to try/use Popularity Contest plugin, but each time I attempt to active it, I have an error message which says:

    Plugin could not be activated because it triggered a fatal error.
    
    Incorrect table name '' on line: 255

    Here is the function written in these lines:

    $result = mysql_query("
    			CREATE TABLE <code>$wpdb->ak_popularity_options</code> (
    				<code>option_name</code> VARCHAR( 50 ) NOT NULL,
    				<code>option_value</code> VARCHAR( 50 ) NOT NULL
    			)
    		", $wpdb->dbh) or die(mysql_error().' on line: '.__LINE__);
    		if (!$result) {
    			return false;
    		}

    I can also tell you that my MySQL settings look like this:

    /** The name of the database for WordPress */
    define('DB_NAME', 'wordpress');

    Your help will be much appreciated — do you have any ideas?

  2. microsleep
    Member
    Posted 3 years ago #

    OK — finally, I have found a solution by myself! ;)

    All you have to do is to get connected to your phpMyAdmin panel and create a new table called ak_popularity containing 2 fields within your WordPress database, et voilà.

  3. repoulin
    Member
    Posted 3 years ago #

    Thanks for the fix on this. It was driving me mad. I really liked this plugin and it was easy to incorporate in various ways and places on the blog.

  4. boothdv
    Member
    Posted 3 years ago #

    i created the table but still receive the same error. what values do i enter for the two fields? i'm not proficient with php/mysql at all but i really need to get this to work. any help is appreciated.

    dave

  5. BloggerSavvy
    Member
    Posted 3 years ago #

    @microsleep

    Please can you let us know what the names of the tables and the names of the fields are?

    I know there are at least two tables:

    • ak_popularity
    • ak_popularity_options

    Thank you

  6. oli4uk
    Member
    Posted 3 years ago #

    I am still having trouble getting this to work, can you provide the exact SQL command you used? would be very much appreciated!

    My next attempt will be to download the Popularity contest tables from another of my sites, import them in to my new site and drop the contents, seems like a whole lot of trouble for nothing though :(

  7. sMartyDs
    Member
    Posted 3 years ago #

    Here's the two tables you need to create

    CREATE TABLE wp_ak_popularity (
    post_id int(11) NOT NULL,
    total int(11) NOT NULL,
    feed_views int(11) NOT NULL,
    home_views int(11) NOT NULL,
    archive_views int(11) NOT NULL,
    category_views int(11) NOT NULL,
    tag_views int(11) NOT NULL,
    single_views int(11) NOT NULL,
    searcher_views int(11) NOT NULL,
    comments int(11) NOT NULL,
    pingbacks int(11) NOT NULL,
    trackbacks int(11) NOT NULL,
    last_modified datetime NOT NULL,
    KEY post_id (post_id)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

    --
    -- Dumping data for table wp_ak_popularity
    --

    -- Table structure for table wp_ak_popularity_options
    --

    CREATE TABLE wp_ak_popularity_options (
    option_name varchar(50) NOT NULL,
    option_value varchar(50) NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1;

  8. sMartyDs
    Member
    Posted 3 years ago #

    I forgot to mention, during testing make sure you allow views from the author otherwise it will continue to read Popularity unranked

  9. Just Ishaq
    Member
    Posted 3 years ago #

    @sMartyDs, thank you very much, Brother... You make my day light... I solved it using your solution...

  10. sanglucci
    Member
    Posted 3 years ago #

    I tried entering the code listed above into the editor program for popularity plugin but after attempting to activate I now have an error on line 283?

    Any ideas on why this is happening?

  11. sanglucci
    Member
    Posted 3 years ago #

    Are these tables duplicates to the already existing tables. Looking at the code for the existing tables looks identical to the ones listed above. I'm kind of a newbie here as I'm sure you can tell. Please help!

  12. sanglucci
    Member
    Posted 3 years ago #

    Ok so I figured out how to access my phpmyadmin panel. I clicked on 'databases' then went down to the create new table section typed in ak_popularity for the name and for number of fields put in 2. Now I get two rows with 'fields', 'type', 'length/values', 'coalition', 'attributes', etc... for the column headers. This is where I am now lost. I don't know what to enter into these boxes to create these tables which would allow the plugin to work.

    Please assist further

  13. sanglucci
    Member
    Posted 3 years ago #

    Wow... so I hit the SQL query button and pasted the code you displayed above. The tables were created and I activated the plugin and it worked!!! Went from a newb to a rockstar LOL. Thanks for this man!

  14. avignonmelimelo
    Member
    Posted 3 years ago #

    Thank you so much sanglucci for giving those step by step instructions! You saved me SO much time :)

  15. sanglucci
    Member
    Posted 3 years ago #

    Nice avignon glad it helped. I now ran into one more problem folks, the plugin works fine but now I can't edit the popularity values in the settings portions. They automatically reset to the default values when I try changing them.

    Any thoughts here?

  16. R P
    Member
    Posted 3 years ago #

    Thanks buddy it worked for me too. Only think I would like to mention here is about the table prefix, "wp_" mentioned above needs to be replaced by yours in case you have different table prefix.

  17. sanglucci
    Member
    Posted 3 years ago #

    RP is this why I'm not able to change the number values to calculate the 'popularity' rankings because I used the wp prefix??

    The plugin works fine after I inputted the above SQL but now I can't change the number values on my dashboard. What other prefix do I need to enter in here? Or how would I find out which table prefix I'm currently using..

  18. sanglucci
    Member
    Posted 3 years ago #

    All of my tables in myadmin start with wp prefix so I don't think this is the problem. Anybody having the same issues with change the default popularity values for the plugin?

  19. joedel263
    Member
    Posted 3 years ago #

    I autoinstalled the version of wordpress that I'm testing on, so it created tables with a prefix of wp_randomstring_ wordpress is looking for the random string as well..

    I've got the tables functional, even got it to not display pages, but it's not recording page views at all (I've got the correct author setting and have hit the site from various computers/phones) It's also only showing a specific five pages in widgets (I've swapped out the different ones available, and faked data in the mysql table for the others but to no avail) I have one post that I commented on 30 times, but because it isn't one of the specific posts it doesn't display.. (it's in the same category, same tags as another post that is displaying) Regardless, if I can't actually get it to count pageviews what good is it?

    I'm going to keep fidgeting with it, but if anyone has any ideas I'd love to hear them.

  20. BloggerSavvy
    Member
    Posted 3 years ago #

    Thanks to those who provided information, I was also able to get this working. For those who need a quick few steps, here's what to do:

    To make it a bit easier for others, you can do the following.

    Access phpMyAdmin for the hosting account (domain) you've installed you WordPress. Select the correct database for your specific WordPress installation. Select the "SQL" tab in the top navigation.

    In the text box entitled, "Run SQL query/queries on database...", place each block of code (see the two blocks below) and then select "Go" (it's a button on the far right).

    ******
    MAKE SURE you substitute the first part of the table name that says "wp", to the table_prefix that you set in your wp-config.php file. Many people lave it as "wp" (but that is not secure), often it's changed to something else (to improve security).
    ******

    CREATE TABLEwp_ak_popularity` (
    post_id INT( 11 ) NOT NULL ,
    total INT( 11 ) NOT NULL ,
    feed_views INT( 11 ) NOT NULL ,
    home_views INT( 11 ) NOT NULL ,
    archive_views INT( 11 ) NOT NULL ,
    category_views INT( 11 ) NOT NULL ,
    tag_views INT( 11 ) NOT NULL ,
    single_views INT( 11 ) NOT NULL ,
    searcher_views INT( 11 ) NOT NULL ,
    comments INT( 11 ) NOT NULL ,
    pingbacks INT( 11 ) NOT NULL ,
    trackbacks INT( 11 ) NOT NULL ,
    last_modified DATETIME NOT NULL ,
    KEY post_id ( post_id )
    )`

    and

    CREATE TABLEwp_ak_popularity_options` (
    option_name VARCHAR( 50 ) NOT NULL,
    option_value VARCHAR( 50 ) NOT NULL
    )`

    NOTE: This forum is altering the syntax of the code. You can see the correct code here: http://rogerwheatley.com/how-to-get-popularity-contest-working-in-wordpress-3-0-4/

  21. sanglucci
    Member
    Posted 3 years ago #

    Is anybody else unable to change popularity values in the admin section? The plugin is also not registering any counts for page views, it's only registering counts for comments and pingbacks.

    If so, anybody have a fix?

  22. stebelskiy2709
    Member
    Posted 3 years ago #

    Yeah it`s working for 3.04 as BloggerSavvy posted

  23. stebelskiy2709
    Member
    Posted 3 years ago #

    Is anybody else unable to change popularity values in the admin section? The plugin is also not registering any counts for page views, it's only registering counts for comments and pingbacks.

    If so, anybody have a fix?

    Plugin is working..The problem maybe is you are trying to update it through self browser I mean viewing pages only one or you have comments on some pages, they are weighter than viewing.. Maybe on your admin CP in plagin`s settings on top 'Ignore views by site authors:' checking 'Yes' - change it to 'No' and you will be able to do first steps I defined.

  24. stebelskiy2709
    Member
    Posted 3 years ago #

    I havent seen this:( Its still broken and unfixed.. The same problem as well as everybody improperly counting

  25. atreidex
    Member
    Posted 3 years ago #

    Thank you sMartyDs!!

  26. giraffe2011
    Member
    Posted 3 years ago #

    I had a go at the plugin and i think there is mistake in
    the way plugin calls the table prefix just find line
    below function check_install() that says this

    $result = mysql_query("SHOW TABLES LIKE '{$wpdb->prefix}ak_popularity%'", $wpdb->dbh);

    and change it into

    $result = mysql_query("SHOW TABLES LIKE '".$wpdb->prefix."ak_popularity%'", $wpdb->dbh);

    that fixes activate reactivate as i discovered every time you reactivete this plugin it tries to create tables that are already there

    now problem eith error on lines 250-255
    actualy it is the way mysql_query is made passing $wpdb variable as part of a string is not a good idea wordpress codex gave me solution to that.
    find the line that says

    $result = mysql_query("
    CREATE TABLE <code>$wpdb->ak_popularity_options</code> (
    <code>option_name</code> VARCHAR( 50 ) NOT NULL,
    <code>option_value</code> VARCHAR( 50 ) NOT NULL
    )
    ", $wpdb->dbh) or die(mysql_error().' on line: '.__LINE__);

    and change it to:

    CREATE TABLE <code>".$wpdb->prefix."ak_popularity_options</code> (
    <code>option_name</code> VARCHAR( 50 ) NOT NULL,
    <code>option_value</code> VARCHAR( 50 ) NOT NULL
    )
    ", $wpdb->dbh) or die(mysql_error().' on line: '.__LINE__);

    and again couple of lines below find ones that say :

    $result = mysql_query("
    CREATE TABLE <code>$wpdb->ak_popularity</code> (

    change them to

    $result = mysql_query("
    CREATE TABLE <code>".$wpdb->prefix."ak_popularity</code> (

    Hope that helps it definately helped me ... im using latest wordpress on my server.
    I will look into other issues a bit later as it is 6 am and i need to catch some sleep LOL

  27. giraffe2011
    Member
    Posted 3 years ago #

    actually the code above is messed up and instead of
    ' there are < code > and < /code >
    it should look like this
    First change:
    where it says:

    $result = mysql_query("
    CREATE TABLE '$wpdb->ak_popularity_options' (
    'option_name' VARCHAR( 50 ) NOT NULL,
    'option_value' VARCHAR( 50 ) NOT NULL
    )

    Should be:

    $result = mysql_query("
    CREATE TABLE '".$wpdb->prefix."ak_popularity_options' (
    'option_name' VARCHAR( 50 ) NOT NULL,
    'option_value' VARCHAR( 50 ) NOT NULL
    )

    and
    second change:
    where it says:

    $result = mysql_query("
    CREATE TABLE '$wpdb->ak_popularity' (

    should be:

    $result = mysql_query("
    CREATE TABLE '".$wpdb->prefix."ak_popularity' (

    Sorry for that i haven't noticed after pasting from PhpED
    that my straight ticks were converted into backticks.

    The very first change of function check install from the post above is correct so no point of pasting it again here.

    cheers

  28. sanglucci
    Member
    Posted 3 years ago #

    I'm done with this plugin it's driving me crazy. I can't change the values because they revert back to the default and also it's not even computing the default values correctly either.

    Until this plugin is fixed I'm done with it!!!

  29. bigthumbs
    Member
    Posted 3 years ago #

    I registered just to reply to this thread. Thank you sMartyDs, I have never done a SQL command, but ran the code you provided and it worked like a charm. I use this plugin without issues on other sites and needed it here after showing the client. THANK YOU !!

  30. myuption
    Member
    Posted 3 years ago #

    That was useful, thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic