Jump to content

Archived

This topic is now archived and is closed to further replies.

MB Works

Echo a PHP Script

Recommended Posts

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 example

Table: 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 HTML
I want to Run <?php something ?>

How i can run that PHP code before the HTML?

Thanks

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.