I think i wont work that way... Storing PHP code mixed with free text in a database, then extract the text in a string variable and get PHP code parsed...
I've done something similar, but used custom tags like [ArticleID] included in text, then replaced them with the appropriate value... But there was a limited set of recognized tags and there was specific code that maked the replacement for each tag...
PHP tags stored in a database will not be executed by the server, because they are not part of any script - they are just string constants. Browser will not show them, because by default it will skip any tag it does not understand, as <?...?> for example.
Now, are You sure storing PHP code in the database can not be avoided? I just can not image any reason for the code to be there...
Sure, but that does not make sense...
1. Extract the text from database in a variable
2. Use a regular expression to match all <?...?> pairs.
3. Parse the text inside and replace all that is a syntactically valid PHP variable with the appropriate value.
4. Output the result to the browser.
and this is the text from one of the database - it only has one small amount of php - so i just post that area.
This seems like a pretty much all ballad cd - but there will be some upbeat
tracks as well! More news when we get it!<br>
You can check out some more news about the album <a href="display.php3?id=50&ref=<?php echo $id ?>">here </a>
It should not...
What version of PHP are You using?
There's a piece of PHP code. Can You start it in Your environement and tell me what's the output?
$id = 5;
$Str = "<br>This seems like a pretty much all ballad cd - but there will be some upbeat tracks as well! More news when we get it!<br>You can check out some more news about the album <a href=\"display.php3?id=50&ref=$id\">here </a>";