Saturday, September 01, 2007

How to evaluate PHP code that store in MYSQL

Woo... i came back to blog something... :)

well, i got married last february 2007, and expecting a baby next year... :) kind a scary that i will became a dad... i wonder how it's goes....

well, today i spend 3 hour to fix some PHP code, and thanks God i found the solution! My problem is how to evaluate(eval) a variable that stored in MySQL database.

the situation is, i got some function that return '$something', and a html template that contain '{something}'. Now i want to replace '{something}' with '$something' which i store in mysql database, my solution is:

[Mysql data fetching here]

$row_mysql['find'] = "{something}";
$row_mysql['replace'] = "$something";

eval("\$replace = \"".$row_mysql['replace']."\";");
$body = stripslashes(ereg_replace($row_mysql['find'], $replace, $body));



hope this helps...

Labels:


0 Comments:

Post a Comment

<< Home