Page 1 of 1

splite and replace code

Posted: Thu Sep 04, 2008 12:26 pm
by jim_php
hello i try to split and replace a mysql result

i have one form to store data and one field called description

in this textarea (description) i write
-----------------
hello all this is a text <code> ?> $4 = 2+2; echo "$4"; <?</code>
------------------

okay now i want to execute the code but ooooonly from <code> to </code>

to use as folowing

$description = $row->description; // hello all this is a text
and
$description = eval($row->description); // 4


echo $description;



any good idea ?

i thin something that

$description .= preg_replace("[<code>]", " "; echo eval( ", $row->description);
$description .= preg_replace("[</code>]", " ); ", $row->description);

echo $description;
but not working

Re: splite and replace code

Posted: Thu Sep 04, 2008 1:03 pm
by jayshields
I'm having a very hard time working out what you are asking! You want a text area to allow <code> ... </code> tags, which can contain PHP code, which when submitted will actually evaluate the code and replace the code and tags with the result?

It already sounds like an enormous security hole, but if you post some more code, preferably in [ php ] tags, and use better punctuation, someone will probably help.