WordPress.org

Support

Support » Plugins and Hacks » Execute PHP code from Database?

Execute PHP code from Database?

  • Hi,

    I’m hacking a plugin, and have found that putting the PHP code into the DB is my best solution (for a variety of reasons).

    I thought that there was a way to put raw html/php code (ie, an entire php page) into the DB (as a single text field) and then execute and display the page.

    so if I have something like:

    <html>
    <?php wp_loginout(); ?>
    <br />
    <?php wp_register(); ?>
    </html>

    if will output a page with a login link and a register link.

    I’ve tried various eval() combination’s, but I either get a blank page, my php code stripped, or I get straight unexecuted text

    What am I doing wrong?

    Thanks

    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
  • whooami

    @whooami

    Member

    umm, putting php into your db for the purpose of outputting it in a page is no different than creating a page that contains PHP thats going to be executed (as in your example above) — and that doesnt work. Not only are you doing things ass-backwards, but ..

    close… but not quite…. I won’t dispute your ass-backwards campaign, but to save on duplication of code in multiple places, a database is a great place to store it and retrieve it… multiple times.

    I come from the land of compiled languages, and PHP/HTML/MySQL interaction is a bit foriegn to me, so I’m learning as I go.

    FWIW – I did decide to do a redirect back to the page I was on , which in effect did the same thing, but I was disappointed that I couldn’t execute a page from the DB. Oh well, I guess I’ll just shake it off as another one added to my learning curve.

    Thanks

    Matt

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Execute PHP code from Database?’ is closed to new replies.
Skip to toolbar