Andy Huang
Sat 6th Nov '04, 10:37pm
Hi all;
I know this must be a ridiculously easy question that I'm simply overseeing due to tiredness, but say I have a string "This is my long string {$PAGEVAR['abc']}", normally, if I have $PAGEVAR['abc'] defined as "for testing.", when I echo it, it should give output: "This is my long string for testing."
Code:
<?php
$PAGEVAR['abc'] = "for testing.";
$foo = "This is my long string {$PAGEVAR['abc']}";
print $foo;
?>
Output:
This is my long string for testing.
Right now, the above works no problem. But if I were to obtain the $foo from a query and do the same thing, it doesn't seem to want to print it?
Code:
<?php
$database = new database($username, $password); // its my nifty little database class...
$PAGEVAR['abc'] = "for testing.";
$result = $database->execute("SELECT string FROM test WHERE sid = 1;");
$row = mysql_fetch_row($result);
$foo = $row['string']; // store "This is my long string {$PAGEVAR['abc']}"
print $foo;
?>
Output:
This is my long string {$PAGEVAR['abc']}.
Am I doing something wrong? Why is it not appearing properly?
I know this must be a ridiculously easy question that I'm simply overseeing due to tiredness, but say I have a string "This is my long string {$PAGEVAR['abc']}", normally, if I have $PAGEVAR['abc'] defined as "for testing.", when I echo it, it should give output: "This is my long string for testing."
Code:
<?php
$PAGEVAR['abc'] = "for testing.";
$foo = "This is my long string {$PAGEVAR['abc']}";
print $foo;
?>
Output:
This is my long string for testing.
Right now, the above works no problem. But if I were to obtain the $foo from a query and do the same thing, it doesn't seem to want to print it?
Code:
<?php
$database = new database($username, $password); // its my nifty little database class...
$PAGEVAR['abc'] = "for testing.";
$result = $database->execute("SELECT string FROM test WHERE sid = 1;");
$row = mysql_fetch_row($result);
$foo = $row['string']; // store "This is my long string {$PAGEVAR['abc']}"
print $foo;
?>
Output:
This is my long string {$PAGEVAR['abc']}.
Am I doing something wrong? Why is it not appearing properly?