Jump to content

echo text that includes php code from database?


dbx

Recommended Posts

I'm storing text in a database and I want to include PHP code in the text.

 

E.g. I store the following in the table:

 

"blah blah blah blah blah <?php echo "hello"; ?> blah blah blah"

 

When my script gets the text from the DB and displays it in the browser, nothing shows up where <?php echo "hello"; ?> is.

 

Could someone please tell me how I should be doing it?

 

Thanks

it's a PHP currency converter

 

it takes the value, checks what currency the user has chosen, does the conversion, formats the result and displays it on the page.

 

 

 

if this can't be done, it's not a problem. it was just a minor improvement rather than a necessity. i'm not going to modify functions or create new ones to do it.

Unless the functions print straight to the page, you made need to echo out the return value of "con()" .. Also don't forget you've got qutoes in there which will trigger an error:

 

$db_text = "blah blah <?php echo con(\"123\"); ?> blah";

 

 

Adam

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.