For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > May 2004 > Variables in database content









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Variables in database content
Brian Stoffer

2004-05-23, 7:30 pm

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
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com