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 Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/ 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. Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111841 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? Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111842 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 Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111845 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! Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111846 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 Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111847 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. Link to comment https://forums.phpfreaks.com/topic/213609-storingrunning-php-in-mysql/#findComment-1111850 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.