R4nk3d Posted September 20, 2009 Share Posted September 20, 2009 I'm making a very dynamic site and i can't seem to figure out how to take lines of php, write them onto a page, and have them output something. here's an example: $mysqlfield = "<?php include('test.php'); ?>"; echo($mysqlfield); But it doesnt write anything, am i able to do this? Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/ Share on other sites More sharing options...
Alex Posted September 20, 2009 Share Posted September 20, 2009 Look into eval() Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-921824 Share on other sites More sharing options...
R4nk3d Posted September 20, 2009 Author Share Posted September 20, 2009 Ok, thanks. Ill look into it because I just changed it and it screwed up the script so Ill have to read up on that to know how to use it. Thanks, R4nk3d Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-921827 Share on other sites More sharing options...
5kyy8lu3 Posted September 20, 2009 Share Posted September 20, 2009 Ok, thanks. Ill look into it because I just changed it and it screwed up the script so Ill have to read up on that to know how to use it. Thanks, R4nk3d it basically executes a string of php code. $a = 'echo "Hello world!";'; eval($a); That would output: Hello world! There's also call_user_func("FunctionName", "Arguments"); if you need to call functions with a string. Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-921874 Share on other sites More sharing options...
R4nk3d Posted September 21, 2009 Author Share Posted September 21, 2009 Ok, well i store pages in the mysql fields for the dynamic site and its kind of like this: Welcome to <?php echo($title); ?> so its a mix of php and html. Should i run a loop through the string and find the <?php parts of it and eval the string in between the <?php and ?> tags? Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-921960 Share on other sites More sharing options...
redarrow Posted September 21, 2009 Share Posted September 21, 2009 you don't need to use eval() php function. hopefully it deleted on php6, it a way off saying hack me please. why not just use plain variables on one page ,and use a include("to_add_the_file_.php"): Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-921965 Share on other sites More sharing options...
R4nk3d Posted September 21, 2009 Author Share Posted September 21, 2009 Because im using dynamic web pages that are taken from a mysql table.... not files. Quote Link to comment https://forums.phpfreaks.com/topic/174921-write-php-from-mysql-field/#findComment-922179 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.