473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

PHP tag in database

Hello,
I have a database that consists of text. This text contains php code
that needs to be processed before echoing it on the browser. A
pseudocode may be:

<?php
/* connect to database */

/* for each record
process the php text in database */
?>

Simply echoing the text will not make the php tags to be processed.
Please let me know if you have any ideas or opinions on how to make
the text information in database to be processed.

Thanks!
Jul 17 '05 #1
8 1716
Subhash wrote:
Hello,
I have a database that consists of text. This text contains php code
that needs to be processed before echoing it on the browser. A
pseudocode may be:

<?php
/* connect to database */

/* for each record
process the php text in database */
?>

Simply echoing the text will not make the php tags to be processed.
Please let me know if you have any ideas or opinions on how to make
the text information in database to be processed.


Look up eval (but be VERY careful what you execute, don't let anyone
else write it to your database)
Jul 17 '05 #2
Kevin Thorpe <ke***@pricetrak.com> wrote in message news:<40***********************@news.easynet.co.uk >...
Subhash wrote:
Hello,
I have a database that consists of text. This text contains php code
that needs to be processed before echoing it on the browser. A
pseudocode may be:

<?php
/* connect to database */

/* for each record
process the php text in database */
?>

Simply echoing the text will not make the php tags to be processed.
Please let me know if you have any ideas or opinions on how to make
the text information in database to be processed.


Look up eval (but be VERY careful what you execute, don't let anyone
else write it to your database)


Thanks Kevin. Thats really helped. But what if the text was something
like this:

<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>

When you do an eval on this it does not work, which is correct. Is
there anyway to properly handle the above case?
Jul 17 '05 #3
Subhash wrote:
what if the text was something like this:

<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>

When you do an eval on this it does not work, which is correct. Is
there anyway to properly handle the above case?


I'd try:

<?php
$text = '<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>';

eval('?>' . $text);
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #4
su**********@yahoo.com (Subhash) wrote in
news:fd**************************@posting.google.c om:
Kevin Thorpe <ke***@pricetrak.com> wrote in message
Thanks Kevin. Thats really helped. But what if the text was something
like this:

<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>

When you do an eval on this it does not work, which is correct. Is
there anyway to properly handle the above case?


How about ... write your data to a temp file and then include that file.

Ken Robinson
Jul 17 '05 #5
su**********@yahoo.com (Subhash) wrote in message news:<fd**************************@posting.google. com>...
Kevin Thorpe <ke***@pricetrak.com> wrote in message news:<40***********************@news.easynet.co.uk >...
Subhash wrote:
Hello,
I have a database that consists of text. This text contains php code
that needs to be processed before echoing it on the browser. A
pseudocode may be:

<?php
/* connect to database */

/* for each record
process the php text in database */
?>

Simply echoing the text will not make the php tags to be processed.
Please let me know if you have any ideas or opinions on how to make
the text information in database to be processed.


Look up eval (but be VERY careful what you execute, don't let anyone
else write it to your database)


Thanks Kevin. Thats really helped. But what if the text was something
like this:

<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>

When you do an eval on this it does not work, which is correct. Is
there anyway to properly handle the above case?


Look at the user notes <http://in2.php.net/eval> especially
eval_html()

--
"I don't believe in the God who doesn't give me food, but shows me
heaven!"--Swami Vivekanandha
Email: rrjanbiah-at-Y!com
Jul 17 '05 #6
Thanks guys, all your suggestions worked great! Thanks, Subhash
Jul 17 '05 #7
Pedro Graca <he****@hotpop.com> wrote in message news:<c2*************@ID-203069.news.uni-berlin.de>...
Subhash wrote:
what if the text was something like this:

<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>

When you do an eval on this it does not work, which is correct. Is
there anyway to properly handle the above case?


I'd try:

<?php
$text = '<htmlcode>Blah Blah</htmlcode>
<?php echo "xyz"; ?>
<htmlcode>Blah Blah</htmlcode>';

eval('?>' . $text);
?>


Pedro,
Your suggestion worked great! But I don't understand how? I mean how
does adding '?>' to the $text make it work?

Thanks
Jul 17 '05 #8
Subhash wrote:
Pedro Graca <he****@hotpop.com> wrote in message news:<c2*************@ID-203069.news.uni-berlin.de>...
eval('?>' . $text);
Your suggestion worked great! But I don't understand how? I mean how
does adding '?>' to the $text make it work?


The '?>' simply says to php:

- Hey! Quit "PHP mode" and evaluate what follows as HTML, parsing
whatever you find between <?php and ?> as PHP.

:)
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Cherrish Vaidiyan | last post by:
sir, The following are the steps that i followed in setting up standby database on Red hat Linux 9. i am using Oracle 9i. i have followed the steps in this site : ...
6
by: Marvin Libson | last post by:
Hi All: I am running DB2 UDB V7.2 with FP11. Platform is Windows 2000. I have created a java UDF and trigger. When I update my database I get the following error: SQL1224N A database...
8
by: Kamlesh | last post by:
Hi, How do I know the physical database path of a database. When I goto the DB2INSTANCE users's directory (/home/db2inst1), I see following folders: /db2inst1/NODE0000/SQL00001...
1
by: pintur | last post by:
The message is: SQL1036C Errore di I/O durante l' accesso al database. SQLSTATE=58030 what is the proble? what for restore tables? thanks
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
8
by: morleyc | last post by:
Hi, until recently i was quite happy to add data sources from mssql database in visual studio and drag the datasets directly onto the form this creating a directly editable form which worked well....
0
by: Jack | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Winder | last post by:
Training Classes for Oracle10g, 9i, 8i Certification training in Oracle10g and 9i: DBA, Developer, Discoverer. training conducted at your location worldwide. Courseware licensing also available....
0
by: Laurynn | last post by:
# (ebook - pdf) - programming - mysql - php database applicati # (Ebook - Pdf)Learnkey How To Design A Database - Sql And Crystal Report # (ebook-pdf) E F Codd - Extending the Database Relational...
9
by: Peter Duniho | last post by:
Is there a straightfoward API in .NET that allows for inspection of a database? That is, to look at the structure of the database, without knowing anything in advance about it? For example,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.