...

View Full Version : php tags from a database.



Tidus
02-05-2003, 07: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, 03: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, 03: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 !

Jesh
02-05-2003, 08:17 PM
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, 01: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.

Jesh
02-06-2003, 02:32 AM
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, 02: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, 03:04 AM
http://www.php.net/manual/en/function.eval.php

Tidus
02-06-2003, 03:05 AM
sorry. i am there and cant figure it out?

firepages
02-06-2003, 03: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, 03:17 AM
Thanks everyone!

Its all working now :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum