Ell360 Posted September 16, 2010 Share Posted September 16, 2010 Hey, I am a bit of a noob at php/mysql and trying to be clever(emphasis on trying). I want to pull some php/html code from a database in mysql, whilst it does display the html, the php does not. Can this even be done? Is it going to cause me issues later on? [code=php:0] <?php $query = "SELECT * FROM pages"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $body = $row["body"]; echo $body; }?> [/code] Any help would really be appreciated. Ell Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 16, 2010 Share Posted September 16, 2010 I assume it can be done. What is your script to put stuff in the database. It could very well be that the script is stripping valuable stuff. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 16, 2010 Share Posted September 16, 2010 It doesn't display or it doesn't execute? Quote Link to comment Share on other sites More sharing options...
Andy-H Posted September 16, 2010 Share Posted September 16, 2010 <?php $query = "SELECT * FROM pages"; $result = mysql_query($query) or die(mysql_error()); while ($row = mysql_fetch_array($result)){ $body = $row["body"]; eval("$body"); }?> eval Quote Link to comment Share on other sites More sharing options...
Ell360 Posted September 16, 2010 Author Share Posted September 16, 2010 Hey, Wow, thanks all for speedy replies! eval() seems to have done it. Thank you! Quote Link to comment Share on other sites More sharing options...
fortnox007 Posted September 16, 2010 Share Posted September 16, 2010 I assume you would never want to give others than admins access to this right? Seems kinda scary if people can upload php to execute later Quote Link to comment Share on other sites More sharing options...
Ell360 Posted September 16, 2010 Author Share Posted September 16, 2010 Yea, hopefully it should be ok when finished... *crosses fingers* . I wrote the code and then inserted it straight into mysql, I wanted to test it before I before I did anymore and found out that I couldn't do it this way. 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.