It's the old eval() woes, isn't it? 😉
Here's some code I use:
## Code db_clean_function ##
function dbCode($text) {
$text = str_replace("$", "\$", $text);
$text = addslashes($text);
return($text);
}
## To insert code ##
$db_code = dbCode($da_code);
$doInsert = mysql_query("insert into codetable values ('', '$chapter_id', '$article_id', '$db_code', 'y', '$username')");
## Your sql may vary from mine ;-) ##
## Pick it out and eval it ##
$query = mysql_query("select code from codetable where chapter_id=$chapter_id");
@ eval (stripslashes(mysql_fetch_array($query)));
I use the db class from phplib, but I think this should work.
Be sure to protect the input/output of such querys! Executing php should be considered carefully 😉
knutm