Variables in database content
| From: | Brian Stoffer | Date: | Sun, 23 May 2004 22:34:13 +0000 |
| Subject: | Variables in database content | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-34531@lists.php.net to get a copy of this message | ||
Hi there. I have what I suspect is an easy one, but was unable to find something similar in the archives (it's a tough one to search for...).
Basically I have a table with a text block column. The actual content that lives in column contains php variables that I want to be able to use when I pull the text out of the database. Let me give you an example:
Content:
"Hi there. My name is $name. This is a bunch of text that $othername is telling me to populate with some data. Hopefully you will be able to help $othername and I get this to work. Thanks!"
Now, in my script I want to be able to pull names out of another table, initialize the $name and $othername variables, then pull out the content above, parse the "names" variables and display it in the browser.
My problem is the variables don't get parsed. I've tried a few obvious things, like storing the text in a variable, using print or echo, and so-on, even processing it with the various text-to-html functions hoping that it would process the variables, but it seems like it's treating the text as a literal and not actually parsing the variables.
I suspect it has something to do with either the order, the method of output, or some pre-processing that I'm missing, but after a few hours I simply can't get it.
Thanks for any advice!
-b