WordPress.org

Ready to get started?Download WordPress

Forums

phpexec and wpdb problem (3 posts)

  1. brooklynwebguy
    Member
    Posted 8 years ago #

    Hi --

    I am having trouble using the wpdb object inside the <phpcode> tags of php exec. When I attempt to access wpdb with code that works when placed directly in a template, I get the following error when I put it in a post via phpexec:

    "Call to a member function on a non-object"

    Is there any way to fix this?

    It seems the combination of phpexec and the wpdb object are very powerful. I would be grateful for any help from an experienced hand.

  2. Kafkaesqui

    Posted 8 years ago #

    Try scoping $wpdb as global first in your <phpcode> call:

    <phpcode>
    global $wpdb;
    ~the rest of your code~
    </phpcode>

  3. brooklynwebguy
    Member
    Posted 8 years ago #

    That did it.

    Thanks!

    That's quite a useful plugin.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.