DEVTRENCH.COM

OpenAds and Wordpress Plugin Conflict Solution

OpenAds and Wordpress Plugin Conflict SolutionIf you've come to this blog recently and found an error message in place of the content, I apologize for that. It was due to an incompatibility with OpenAds and the Popularity Contest plugin for wordpress. I shut off the plugin yesterday when I discovered what was going on and found the fix this morning. I thought I would share it with you all.

Basically this is what is going on (quoted from the forum post linked below)

Here's the sequence of events that leads to the conflict:

The error that I was getting looked like this:

the table jamese_openads.wp_ak_popularity_contest does not exist

As you can see it was indeed trying to use the open ads database I set up to access the wordpress plugin table.

The error message that you get only came up for me the first time I would view the homepage or any subsequent pages. I was slow about catching this one since it appeared that the problem would go away when I'd do a refresh, but Googleing "openads wordpress conflict" is what saved the day.

The solution is very easy. You can do one of 2 things:

  1. Don't use the local invocation method for OpenAds. I want to use the local invocation method because I want my ads to be seen by everyone, not just people with Javascript turned on.
  2. Insert this code verbatim in after your invocation code:

    < ?php
    $wpdb->wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    ?>

    So now your invocation code should look something like this:

    < ?php
    // The MAX_PATH below should point to the base of your Openads installation
    define('MAX_PATH', '/your/path/to/openads');
    if (@include_once(MAX_PATH . '/www/delivery/alocal.php')) {
    if (!isset($phpAds_context)) {
    $phpAds_context = array();
    }
    $phpAds_raw = view_local('', 3, 0, 0, '', '', '0', $phpAds_context);
    echo $phpAds_raw['html'];
    }
    ?>
    < ?php
    $wpdb->wpdb(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
    ?>

    That's it.

Thanks to BobbyH for coming up with the fix which I found on the OpenAds Forum. The End