slyte33 Posted December 18, 2009 Share Posted December 18, 2009 Is it possible to execute a php code inside of a mysql table then doing something like: $query=$db->execute("select * from example"); $code = $query->fetchrow(); echo $code[php_codes]; The field [php_codes] would contain something like: <? echo "hello"; ?> Thanks Link to comment https://forums.phpfreaks.com/topic/185634-possible-to-useexecute-php-codes-in-a-mysql-table/ Share on other sites More sharing options...
oni-kun Posted December 18, 2009 Share Posted December 18, 2009 Yes, You can use the command eval to do this very purpose. But I warn you, Make 100% sure that what goes into it is sanitized and safe. You don't want arbituary commands being shoved in there, that can be durastic. Link to comment https://forums.phpfreaks.com/topic/185634-possible-to-useexecute-php-codes-in-a-mysql-table/#findComment-980238 Share on other sites More sharing options...
slyte33 Posted December 18, 2009 Author Share Posted December 18, 2009 How does eval() work? Im having a hard time understanding it. Link to comment https://forums.phpfreaks.com/topic/185634-possible-to-useexecute-php-codes-in-a-mysql-table/#findComment-980247 Share on other sites More sharing options...
oni-kun Posted December 18, 2009 Share Posted December 18, 2009 Try this: <?php eval(' $string = "this"; echo $string . " - "; echo strlen($string); '); ?> And you'll notice it'll parse that very PHP code. You can pull it out of the database and wrap it within eval(). Just note you don't need the tags, you should strip them out. Just the code is fine with the function. Link to comment https://forums.phpfreaks.com/topic/185634-possible-to-useexecute-php-codes-in-a-mysql-table/#findComment-980256 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.