How to use php code stored in mysql database?

Question by WWW.MYHIBRID.COM: How to use php code stored in mysql database?
I know how pull data from the database but I have stored within the a mysql field some text data. Within that that text I have put in some php variables. The problem is that when the browser renders the data that pulled from my sql, the variable stays as $ user for example rather than changing to what I needed to. Is there any way to have the server process the php code stored within the mysql database?

Best answer:

Answer by dhvrm
If you mean you have stored some page code in a MySQL field; in that data, there is PHP code; and you want that data to be evaluated as PHP code, you just call eval().

0) {
$ row = mysql_fetch_array($ rs);
eval($ row[‘column’]);

What do you think? Answer below!


There are no revisions for this post.

Tags: , , , ,

One Response to “How to use php code stored in mysql database?”

  1. lordgun2 November 8, 2011 at 8:33 PM #

    You can use json : it handles encoding/decoding variables.

    If you have a big object like $ object, insert into mysql json_encode($ object) and later you’ll be able to retrieve it by using $ object=json_decode($ data)
    where $ data is the correct mysql field

Leave a Reply