AbydosGater Posted November 12, 2006 Share Posted November 12, 2006 Hi,I have all my menus and pages stored im my database,And i want to be able to run code within my pages, but when i put php in the database, and run the page, its just displayed as a string, how do i get it to run the code itself??Thanks Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/ Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 This is usually a poor design choice, but if you must, evil [url=http://php.net/eval]eval[/url] is what your looking for. Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/#findComment-123524 Share on other sites More sharing options...
AbydosGater Posted November 12, 2006 Author Share Posted November 12, 2006 Thanks, And why is it a poor choice? Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/#findComment-123525 Share on other sites More sharing options...
trq Posted November 12, 2006 Share Posted November 12, 2006 Because it makes your application wide open to security vulnerabilities if your not real carefull. There is usually much easier, more secure ways of doing whatever it is your trying to do without storing php within the database itself. Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/#findComment-123531 Share on other sites More sharing options...
AbydosGater Posted November 12, 2006 Author Share Posted November 12, 2006 Well i am using the function...<?PHPfunction buildMenu($location){$query = "SELECT * FROM agc_menus WHERE location='$location' AND active='1'";$result = mysql_query($query);while ($menurow = mysql_fetch_assoc($result)){$title = $menurow['title'];$content = $menurow['content'];echo <<<MENUITEM<table style="BORDER-COLLAPSE: collapse" height=37 cellspacing=0 width=137> <tbody> <tr> <td valign=top colspan=3 height=18 background=images/menu_top.gif> <p align=center><span style="FONT-SIZE: 7pt"><font color="#FFFFFF">$title</font></span></p> </td> </tr> <tr> <td valign=top width=9 background=images/left.gif height=96> <p> </p> </td> <td valign=top width=112 height=96> <font color="#FFFFFF">$content</font> </td> <td valign=top width=8 background=images/right.gif height=96> <p> </p> </td> </tr> <tr> <td valign=top background=images/menu_bot.gif colspan=3 height=18> <p> </p> </td> </tr> </tbody> </table> <br />MENUITEM;}};?>It pulls all the menus i have in the database, and displays them in a table on the $location, of the page, ie: left, right....But in some of these menus i want to have like users online and things like that!This is the only way i can think!, i was going to create a function to dosplay the users and just put the function in the database, not aload of code!Any other ideas?? Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/#findComment-123535 Share on other sites More sharing options...
AbydosGater Posted November 12, 2006 Author Share Posted November 12, 2006 Ok, Im Lost With The eval(), i want to have the buildCopyright(); function run from the database, how do i eval() it?Please help Link to comment https://forums.phpfreaks.com/topic/27014-run-code-from-the-database-displaying-as-string/#findComment-123556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.