Justtechjobs.com Find a programming school near you






Online Campus Both


php-general | 2001072

[PHP] Execute mixed php code from mysql? From: Kyle (nitro <email protected>)
Date: 07/31/01

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe <email protected>
For additional commands, e-mail: php-general-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>