Title: Execute PHP code from Database?
Last modified: August 19, 2016

---

# Execute PHP code from Database?

 *  [tazatek](https://wordpress.org/support/users/tazatek/)
 * (@tazatek)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/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](https://wordpress.org/support/users/whooami/)
 * (@whooami)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/execute-php-code-from-database/#post-831416)
 * 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 ..
 *  Thread Starter [tazatek](https://wordpress.org/support/users/tazatek/)
 * (@tazatek)
 * [17 years, 10 months ago](https://wordpress.org/support/topic/execute-php-code-from-database/#post-831466)
 * 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.

## Tags

 * [eval](https://wordpress.org/support/topic-tag/eval/)
 * [MySQL](https://wordpress.org/support/topic-tag/mysql/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 2 participants
 * Last reply from: [tazatek](https://wordpress.org/support/users/tazatek/)
 * Last activity: [17 years, 10 months ago](https://wordpress.org/support/topic/execute-php-code-from-database/#post-831466)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
