eviktore Posted June 29, 2010 Share Posted June 29, 2010 Hi, The subject might be confusing. The thing I am trying to do is that I want to create a new row in a MySQL database, and in one of the fields I want to insert some PHP code. So that i can request that field from a browser and show the result of the code. The problem is that when I try to create this database entry with a php statement the variables in the code to be inserted are handled as variables in the statement trying to insert in the database. The challenge is hence to write the varibles as plain text, while they still will be regognized as variables when i request the script later. The MySQL database is actually a joomla site and the code is supposed to be the introtext of an article in jos_content. The code I want to insert is the following: <?php // These variables are picked up by the script that is inserting $id = explode(":", $_GET['id']); $bo = $id['1']; // I select the different properties from another database $result = mysql_query("SELECT * FROM oversikt WHERE id='$bo'") or die(mysql_error()); $row = mysql_fetch_array($result); ?> <head> </head> <body> <ul> <li>Header 1 <ul id='he1'> <li>Sub1: <?php echo $row['s1']; ?></li> <li>Sub 2: <?php echo $row['s2t']; ?></li> <li>Sub3: <?php echo $row['s3']; ?></li> <li>Mark: <?php if ($row['s4']==1) echo "Yes"; else echo "No"; ?> </li> </ul> </li> </ul> </body> Any ideas? Quote Link to comment Share on other sites More sharing options...
trq Posted June 30, 2010 Share Posted June 30, 2010 All you need to really do is put your code into a string, then insert it into the database. What exactly is the issue? Why you would want to be executing code stored within a database however is beyond me. Quote Link to comment Share on other sites More sharing options...
eviktore Posted June 30, 2010 Author Share Posted June 30, 2010 I solved it myself, $ = /$ and then it worked! 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.