MB Works Posted March 10, 2006 Share Posted March 10, 2006 Hey.Im having a problem, and i cant find the solution because i really dont know the command for do it.I have a DB with scripts. For exampleTable: Test, Column: Script, Row: <?php something ?>I want to run that PHP code. But if i do and echo display "<?php something ?>";[code]$query = "SELECT * FROM codes";$result = mysql_fetch_array($query, MYSQL_ASSOC);echo $result['script'];[/code]Where script = "<?php something ?>"And echo return "<?php something ?>" as HTMLI want to Run <?php something ?>How i can run that PHP code before the HTML?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/4579-echo-a-php-script/ Share on other sites More sharing options...
k.soule Posted March 10, 2006 Share Posted March 10, 2006 Use eval(), it will look something like --eval($result['script'];);maybe eval($result['script'] . ';');I'm not sure of the syntax, I have never used it. Quote Link to comment https://forums.phpfreaks.com/topic/4579-echo-a-php-script/#findComment-16014 Share on other sites More sharing options...
MB Works Posted March 10, 2006 Author Share Posted March 10, 2006 It worked, but now my problem is:[code]$var = "<table><tr><td><?php echo "dynamicvalue" ?></td></tr></table>";echo eval($var);[/code]Return:[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Parse error: parse error, unexpected '<' in functions.php : eval()'d code on line 1[/quote]eval only work if: [b]eval("echo dynamicvalue;")[/b]Theres a way to run a Mixed Variable? or i need to filtrer all the code (god)And Thanks for the reply Quote Link to comment https://forums.phpfreaks.com/topic/4579-echo-a-php-script/#findComment-16019 Share on other sites More sharing options...
MB Works Posted March 10, 2006 Author Share Posted March 10, 2006 I got it[code]ob_start();eval ('?>' . $text);$text = ob_get_clean();[/code]Thanks Quote Link to comment https://forums.phpfreaks.com/topic/4579-echo-a-php-script/#findComment-16024 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.