Re: Execute mixed php code from mysql?

From: Date: Tue, 31 Jul 2001 22:20:30 +0000
Subject: Re: Execute mixed php code from mysql?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-60520@lists.php.net to get a copy of this message
the way i have solved this is to have another column of data_type. switch ($data_type) { case "php": exec($data); break; case "html": include($data); break; } mike on 7/31/01 3:24 PM, Kyle at nitro@wi.rr.com wrote: > 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 > > -- mike cullerton

« previous php.general (#60520) next »