View Full Version : php tags from a database.
Tidus
02-05-2003, 06:39 AM
Hello!
I currently have <?php ?> tags in my database but when i look at the page that calls that record nothing shows up, it just shows the tags in the page source.
Does anyone know how to fix this?
James
mordred
02-05-2003, 02:04 PM
Originally posted by Tidus
I currently have <?php ?> tags in my database but when i look at the page that calls that record nothing shows up, it just shows the tags in the page source.
Broken as designed?
In other words, is there a specific reason you store PHP source code in the database? Why don't use a simple include_once or require_once to import PHP source code into a script? Perhaps a little bit of source code helps clearing up your issue...
firepages
02-05-2003, 02:22 PM
.. you can eval($from_db) as well though in that case you dont need the <? ?> tags as eval() appears to add them for you, but I am with Mordred in that it seems a strange way to go about things !
Hey
If you are retrieving from a DB, then how are you going to make PHP process the script?
:confused:
Jesh
Spookster
02-06-2003, 12:09 AM
Originally posted by Jesh
Hey
If you are retrieving from a DB, then how are you going to make PHP process the script?
:confused:
Jesh
Using eval() just like firepages said.
Hey
firepages says eval() adds the tags and doesn't mention script execution. But sorry, I didn't know it also executes the script, I have never called script from a DB.
Jesh
Tidus
02-06-2003, 01:53 AM
Ok so the row is called news.
so how exactly would i use the eval() function. I am only a newbie so yeh..
I have tried a few things but cant figure it out.
James
Spookster
02-06-2003, 02:04 AM
http://www.php.net/manual/en/function.eval.php
Tidus
02-06-2003, 02:05 AM
sorry. i am there and cant figure it out?
firepages
02-06-2003, 02:15 AM
eg
<?
$yaks=mysql_query("SELECT code FROM tester");
$str=mysql_result($yaks,0);
eval($str);
?>
where code in tester is..
for($x=0;$x<=10;$x++){echo "allo from MySQL \n<br />";}
note that eval() can be a real pain at times.
Tidus
02-06-2003, 02:17 AM
Thanks everyone!
Its all working now :)
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.