Reply to Re: executing PHP code from db?

Your name:

Reply:


Posted by coolsti on 06/18/05 10:32

On Sat, 18 Jun 2005 03:57:09 +0000, mjamm wrote:

> Hello
>
> Is there any way to execute PHP code from a database on to a .php browser
> page?
>
> Basically, I am using 'LONGTEXT' to save HTML and other info to output to
> the screen. Works well!
>
> I have tried saving something simple like <?php echo "HELLO!"; ?> to the db
> and then calling it from the database, having the output perform the script
> on to the screen.
>
> Does this make sense?
> thanks

I think you need to consider the steps which occur when presenting an html
page with PHP. This will allow you to better understand the answer to your
question.

The PHP part of your page is not sent directly out to the browser, but is
parsed and executed on the server side. Any output to the browser by PHP
is initiated by PHP using, for example, the echo statement.

So if you wish to store PHP code in your database, and then use it to
present a page, you first need to get the code out of the database, and
then get that code executed on the server side as PHP code. You want to do
basically a database enablement of the "require" statement in PHP. The
"require" statement will name a php script file that must be read into the
current script and parsed as PHP (it may not be PHP, depending on the
various tags within the file, but that is not the point here). What you
want to do instead is perform an SQL query, and read the database script
into some point in your script and execute it.

I never tried this myself, and on this Saturday morning can't really think
of the way to do it, but I am certain it must be possible.

Hope this helps.

- steve

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация