Jump to content

eval() for mysql containg HTML & PHP


vanderlay

Recommended Posts

hi All,

I have a mysql field that contans html code that is echo'd thru a php page, ie

db field = <h1>this is page content</h1>

[code]
$myseldb = mysql_select_db($database, $db1);
$query =  "SELECT * FROM pages WHERE html  = '$pagenum' ";
$recset = mysql_query($query, $db1) or die(mysql_error());
$html = mysql_result($recset, 0, 'pages_html');

echo $html;
[/code]

and works fine generating the html code as expected,
I now need to add some extra php code to do a require, ie

db field = <h1>this is page content</h1>
              <?php require $_SERVER["DOCUMENT_ROOT"].'/extrastuff.php'; ?>

how do i use the eval to parse the html and PHP code then echo it as normal, or is there a better funct then eval,

i have tried this code with no luck
[code]
eval("\$html = \"$html\";");
echo $html;
[/code]




thanks
Art
Link to comment
https://forums.phpfreaks.com/topic/27296-eval-for-mysql-containg-html-php/
Share on other sites

Chances are if your storing php within a database then you have made a poor design choice in the first place. You may however be able to work around your mistakes using output buffering. Take a look at [url=http://php.net/ob_start]ob_start[/url] and its related functions.
[quote author=thorpe link=topic=115026.msg468214#msg468214 date=1163559835]
Chances are if your storing php within a database then you have made a poor design choice in the first place. You may however be able to work around your mistakes using output buffering. Take a look at [url=http://php.net/ob_start]ob_start[/url] and its related functions.
[/quote]

Thx for the direction Thorpe, however I fail to see your connection to how this helps me. Can you provide a little more detail on what functions i can use that will parse the content of the db field so the html is echo'd and the php is processed rather than written to screen as text.

thx again
Art
thx guys, Orio I will give this a go, Jenk, I do have more than just HTML code as the code comes from several sources it may contain a variety of php functs from date/time to who knows what so the processing is important, security is not an issue as this is internal for testing different setups

Art

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.