|
Posted by Marek Kilimajer on 05/16/05 01:38
blackwater dev wrote:
> Hello,
>
> this works fine:
>
> $name="fido";
> $string="my dog's name is $name";
> echo $string;//prints my dog's name is fido
>
> but when I store the string "my dog's name is $name" in the db and pull it out:
>
> //do the query
> $row=$datab->fetch();
> $name="fido";
> $string=$name['db_column'];
> echo $string//prints my dog's name is $name
>
> How can I get it to work with the db?
eval is an answer, but str_replace is much more secure:
$string = str_replace('$name', $name, $string);
Navigation:
[Reply to this message]
|