Jump to content

using code as a field


ianco

Recommended Posts

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

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.

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.