ianco Posted July 3, 2010 Share Posted July 3, 2010 Hi all, I want to use a db table to store code so that I can use it as you would when using the include() function. The code to display the caller code is $appID = $_GET['appID']; $sql="SELECT * FROM apps WHERE appID='$appID'"; $result=mysql_query($sql); while ($row=mysql_fetch_array($result)) { $appCode=$row["appCode"]; $apptitle=$row["apptitle"]; echo "<b>" . $apptitle . "</b><br>"; echo $appCode; } The code that is contained in the table field is some thing like echo ' <table align="left"> <form action="chem.php?appID=1" method="post">[i]SOME TABLE STUFF[/i]</form> </table>'; $moles = $_POST["moles"]; $mass = $_POST["mass"]; $weight = $_POST["weight"]; if(somestuff){somemore stuff } so obviously this doesn't work as when a ; is read it stops the intended use. Does anyone know if there is a way around this or if it is even possible. I don't really want to go the include() route Thanks in advance Ian Link to comment https://forums.phpfreaks.com/topic/206612-using-code-as-a-field/ Share on other sites More sharing options...
Mchl Posted July 3, 2010 Share Posted July 3, 2010 Use eval to run code fetched from database. Be very careful, as this is potential way someone may attack your site. I don't really want to go the include() route Why? Link to comment https://forums.phpfreaks.com/topic/206612-using-code-as-a-field/#findComment-1080627 Share on other sites More sharing options...
ianco Posted July 3, 2010 Author Share Posted July 3, 2010 cheers,, and as for why, i just wanted to avoid having loads of files, when i could have everything in one table may or may not be the best option Link to comment https://forums.phpfreaks.com/topic/206612-using-code-as-a-field/#findComment-1080715 Share on other sites More sharing options...
Mchl Posted July 3, 2010 Share Posted July 3, 2010 cheers,, and as for why, i just wanted to avoid having loads of files, when i could have everything in one table may or may not be the best option One thing to remember is that eval() slows down your script, because it triggers recompilation of entire script on each call. Link to comment https://forums.phpfreaks.com/topic/206612-using-code-as-a-field/#findComment-1080837 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.