renoor Posted April 1, 2007 Share Posted April 1, 2007 hello, this is my first post and also first problem I was unable to find through google... I need a page that can generate it's content completely dynamically, so in database i have objects like image, text, gallery and one special "custom" object - this should be any code in PHP that i want to execute during page generation. So basically, I need something like this: $query="SELECT * FROM subcat WHERE cat = $cat"; $result=mysql_query($query); if (mysql_numrows($result) > 0) $i=0; while ($i < $num) { if (mysql_result($result,$i,"type") == "custom") include (mysql_result($result,$i,"content)); } of course, the 'include' statement is wrong because i'm not supplying a filename with some content, but a content itself. a workaround should be to create a temporary file and include it, but I think it is an ugly solution...please can you help me with this? Link to comment https://forums.phpfreaks.com/topic/45142-how-to-treat-text-from-mysql-as-a-php-code/ Share on other sites More sharing options...
kenrbnsn Posted April 1, 2007 Share Posted April 1, 2007 You probably want to look at the eval() function. Be forewarned that this function can be very dangerous when used with data that comes from an external source. Ken Link to comment https://forums.phpfreaks.com/topic/45142-how-to-treat-text-from-mysql-as-a-php-code/#findComment-219141 Share on other sites More sharing options...
renoor Posted April 1, 2007 Author Share Posted April 1, 2007 thank you very much! the "custom" content will come only from the admin of the site, so no worries ;o) Link to comment https://forums.phpfreaks.com/topic/45142-how-to-treat-text-from-mysql-as-a-php-code/#findComment-219147 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.