Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Fri Aug 27, 2004 2:24 pm
Oke maby kinda stupid but there must be a way to be able to do this.
i tried out a simple thing like the following
I had this code in a database field
Than i retrieved that row from the database trying to have it displayed on the page. However it didnt do that.
When just using text like "Hello World", it would nicely print out "Hello World"
Is there a way to be able to retrieve html and php code from the database ? Or what is the best way to do this.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 2:30 pm
[php_man]eval[/php_man].. be careful though
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Fri Aug 27, 2004 2:36 pm
Howcome what is the downside of using that ? Is there a better way ?
edit: Every html code has to be echo'd with php .. Hmm can that be changed ?
Last edited by
ol4pr0 on Fri Aug 27, 2004 2:42 pm, edited 1 time in total.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 2:40 pm
blindly eval'ing code can create problems if someone is able to insert code that say... deletes the entire site.
ol4pr0
Forum Regular
Posts: 926 Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador
Post
by ol4pr0 » Fri Aug 27, 2004 2:46 pm
What is a other option.. besides putting the whole code in pages lol, i want to be possibel to get as much as i can from the database. However some pages include some queries. So how to get them into the code that i am retrieving from the database
Lets say
#in database
<?
<body>
</body>
?>
Now i want to insert content. which is also stored in database.
Which needs to be between the body tags. or tables.. or whatever..
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Fri Aug 27, 2004 2:52 pm
if you want it for content... look into using templates. for instance, assume the following is stored in a field inside the database
Code: Select all
<body>{DATA}</body>Code: Select all
echo str_replace('{DATA}','this is inserted content',$text);