Guest thegooner Posted July 3, 2006 Share Posted July 3, 2006 HiI have a field in a database that contains a mixture of html and phpexample:<table><tr><td>hello world</td><td><?php echo "hello again"; ?></td></table>I want to call this and execute it within a php page.I get the above text from the database and load it into a variable called $dtext.How do I execute the php within the html I just got form the database.I've tried using "eval" but only get a blank page.Anyone help on this one?Thanks Quote Link to comment Share on other sites More sharing options...
effigy Posted July 3, 2006 Share Posted July 3, 2006 [code]<?php $mixture = <<<MIX <html> <body> Today is <?php \$date = getdate(); echo \$date['weekday']; ?>. </body> </html>MIX; echo eval('?>' . $mixture . '<?php'); ?>[/code] Quote Link to comment Share on other sites More sharing options...
Gooner Posted July 3, 2006 Share Posted July 3, 2006 No, that doesn't work. Quote Link to comment Share on other sites More sharing options...
effigy Posted July 3, 2006 Share Posted July 3, 2006 Perhaps you should be more specific. [i]What[/i] doesn't work? Are you getting an error from the code I posted? Did you try implementing it into what you have? Help is mutual... Quote Link to comment Share on other sites More sharing options...
TheIdeaman Posted August 19, 2006 Share Posted August 19, 2006 Droping the '<?php' part worked for me.Change:[code]echo eval('?>' . $mixture . '<?php');[/code]To:[code]echo eval('?>' . $mixture);[/code]That should do it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.