Execute PHP code from Database? (3 posts)

  1. tazatek
    Posted 7 years ago #


    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:

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

    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?



  2. whooami
    Posted 7 years ago #

    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 ..

  3. tazatek
    Posted 7 years ago #

    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.



Topic Closed

This topic has been closed to new replies.

About this Topic