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?
Related posts:
- How To Code A Simple Php Dynamic Dropdown Form Feild From Mysql? I been struggling with this all morning. I am tiring...
- How Do I Get The Radio Button For Sex To Go To A Database Using Php When using php what value would I have to set...
- display MySQL database rows alphabetically Learn more about display MySQL database rows alphabetically by visiting...
- count the number of rows ina MySQL database Learn more about count the number of rows ina MySQL...
- Display rows from only a certain category of a MySQL database Learn more about Display rows from only a certain category...
Related posts brought to you by Yet Another Related Posts Plugin.


November 4th, 2009 at 11:27 pm
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().
< ?php
//your DB connection data goes here
$rs = mysql_query("SELECT column FROM table") or die("cannot execute query");
if(mysql_num_rows($rs) > 0) {
$row = mysql_fetch_array($rs);
eval($row['column']);
}
?>
November 4th, 2009 at 11:27 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