Online Shopping : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to
Did You Find This Entry Useful?

23 of 39 people (59%) answered Yes
Recently 7 of 10 people (70%) answered Yes


how can i store php code & query in mysql database and get all to execute when retrieved

Mar 15th, 2008 18:08
ha mo, Matthew Wilkinson, mr robinsf,

You can just store them as strings in the database, and then when you
retrieve them from the database just run them like this:
Here is an example of the full code:
$PHPcode = "echo \"This PHP code was taken from a database\";";
mysql_query("INSERT INTO tablename SET column='" . $PHPcode . "'");
$result = mysql_query("SELECT column FROM table");
$PHPcodefromDB = mysql_fetch_row($result);
This should output:
This PHP code was taken from a database