PHP within TEXT in a database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

PHP within TEXT in a database

Post by Gen-ik »

I'm not sure if this is possible, if it is I'm guessing it has something to do with using Eval().

Let's say I have some text in a database which looks something like this..

"Hello. My name is Bob and I've been here <?php a_function('Bob'); ?> times since I started."

Is it possible to run the PHP part of this before the text gets Echo()'ed to the page without having to split up the whole string of text to find any PHP within it?
User avatar
bender
Forum Newbie
Posts: 11
Joined: Sun Jan 12, 2003 6:53 am
Location: Sydney Australia

Post by bender »

Dunno for sure, but perhaps printf() instead of echo"" might be useful?

Post the solution if you find one - I'm keen to know myself :)
superwormy
Forum Commoner
Posts: 67
Joined: Fri Oct 04, 2002 9:25 am
Location: CT

Post by superwormy »

eval ("?>" . $texttoevaluateandsendtopage . "<?php");
Gen-ik
DevNet Resident
Posts: 1059
Joined: Mon Aug 12, 2002 7:08 pm
Location: London. UK.

Post by Gen-ik »

superwormy wrote:eval ("?>" . $texttoevaluateandsendtopage . "<?php");
Fantastic! Cheers mate.
Post Reply