Execute mixed php code from mysql?

From: Date: Tue, 31 Jul 2001 21:24:17 +0000
Subject: Execute mixed php code from mysql?
Groups: php.general 
Request: Send a blank email to php-general+get-60514@lists.php.net to get a copy of this message
For example I have in a database: ----------------------------- In database: <html><head><title>welcome</title></head> <body> <? if ($something == 'hello') { echo 'do somethoing'; }?> ------------------------------ Also in Database: </body></html> ------------------------------- Now how could i make it so that I have another page that has the following: -------- index.php --------- <? $db = mysql_connect ($dbhost,$dbuser,$dbpass); $query = "SELECT code FROM templates WHERE name = 'header'"; $result = mysql_db_query($dbtabe,$query); $row = mysql_fetch_array ($result); echo $row[code]; ?> Jump out and have some html content <? $db = mysql_connect ($dbhost,$dbuser,$dbpass); $query = "SELECT code FROM templates WHERE name = 'footer'"; $result = mysql_db_query($dbtabe,$query); $row = mysql_fetch_array ($result); echo $row[code]; ?> -------------- end page ---------- For some reason it converts the tags on the php code as it pulls it out, i figure echo isn't the right function to do this and echo is converting the '<?' to '&lt;?'. I tried eval(), I need a function similar to include(), but can take strings instead of files. If the content that was in the database and I include()'d it, it would have the desired effect. Thanks in advanced - Kyle

« previous php.general (#60514) next »