Hi,
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...
display.php3 - this file includes a file news.php3
- which gets stuff from the database - that works fine.
But when i store php tags into the database, they dont show up in news.php3. if you view the source of the page, they are there in full. they dont show up on the broswer window..
i have tried everything and i just cant get it right!
OK,
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.
PHP Code:
<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=<?php echo $id ?>">here </a>
Ok, I see...
Try just to change the part of code that stores all this in the database so that it sotores $id instead of <?php echo $id ?>.
PHP will replace it with its value authomatically...
Hmm,
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>";