billbenson
09-02-2008, 03:30 PM
I've been trying to find the answer on this for a few days. What I'm doing is a lot more complicated than this, but here is a simple example of the problem. I have a page with some variables on it. I select some text that includes a variable names from a mysql db. I need to insert the variable into a variable. Here is an example:
this works:
$var='bob';
$var1="my name is $var";
echo $var1;
result: my name is bob
This doesn't work:
$var='bob';
$var1=SELECT RESULT ( my name is $var) //this is selected from the db
echo $var1
result: my name is $var
I've tried adding quotes to the db entry, concertinaing it ie $var1='my name is '.$var; Anything else I can think of. It treats the variable within a variable as text when pulled from the db, but treats it as a variable when everything is done on the page.
this works:
$var='bob';
$var1="my name is $var";
echo $var1;
result: my name is bob
This doesn't work:
$var='bob';
$var1=SELECT RESULT ( my name is $var) //this is selected from the db
echo $var1
result: my name is $var
I've tried adding quotes to the db entry, concertinaing it ie $var1='my name is '.$var; Anything else I can think of. It treats the variable within a variable as text when pulled from the db, but treats it as a variable when everything is done on the page.