If I have something like hello $myvar as the value for a MySQL field named data, how do I get PHP to parse this value after I select it from the database?
For instance if I code:
<?php
// MySQL field named data has value: hello $myvar
$myvar = "world";
$sql = "SELECT data FROM the_table WHERE id='1'";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
$output = $row["data"];
echo $output;
// $output value is:
hello $myvar
?>
I would like the $output value to be: hello world, but I can't get PHP to parse $row["data"] first! It is driving me crazy! Any help is greatly appreciated.
What really confuses me is that:
<?php
$myvar = "world";
$output = "hello $myvar";
echo $output;
?>
works fine as expected. So why does it not work with the MySQL method?
Best,
Jhaura