Ask a Question related to PHP Development, Design and Development.
-
Michael Volk #1
php+mysql-driven webpage
Hi!
I have a little problem:
I have php-code stored in a mysql-table.
How do i run this code?
if i echo it, i see the code, but how do i run it?
thx,
Michael
Michael Volk Guest
-
Creating variable driven MYSQL queries?
I've been looking at hand coding my PHP MYSQL queries, and sort of getting the hang of them, but one thing is bothering me. Everyone seems to build... -
MySQL driven website using Apache- HELP?
If somebody could help me on this it would be appreciated. I have a perl page on my Apache server that is supposed to connect to a database and... -
PHP webpage like MySQL, PART 2
Many hanks for ya'lls help earlier. I've figured out how to pull the data and edit it: http://www.hedges.org/aoii/olemiss/updatesister.php ... -
PHP Webpage like MySql- need to be able to see all fields and edit
Hello. I am building a webpage for a sorority- http://www.olemissaoii.com . I built a basic php script where they add the sisters and their... -
[PHP] PHP Webpage like MySql- need to be able to see all fields and edit
Hello. I am building a webpage for a sorority- http://www.olemissaoii.com . I built a basic php script where they add the sisters and their... -
Pedro Graca #2
Re: php+mysql-driven webpage
Michael Volk wrote:
eval() it.> I have php-code stored in a mysql-table.
> How do i run this code?
>
> if i echo it, i see the code, but how do i run it?
[url]http://www.php.net/eval[/url]
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
--= Size below 10K =--
Pedro Graca Guest
-
Michael Volk #3
Re: php+mysql-driven webpage
hi!
thx for that...
there is not only php-code in this field, but theres also html.
is eval() working for that to?
its a complete site with html AND php-code stored.
thx,
Michael
"Pedro Graca" <hexkid@hotpop.com> schrieb im Newsbeitrag
news:bq78lk$1vfe93$1@ID-203069.news.uni-berlin.de...> Michael Volk wrote:>> > I have php-code stored in a mysql-table.
> > How do i run this code?
> >
> > if i echo it, i see the code, but how do i run it?
> eval() it.
>
> [url]http://www.php.net/eval[/url]
> --
> --= my mail address only accepts =--
> --= Content-Type: text/plain =--
> --= Size below 10K =--
Michael Volk Guest
-
Kevin Thorpe #4
Re: php+mysql-driven webpage
Michael Volk wrote:
IIRC eval starts in <?php context so if you have a complete webpage> hi!
> thx for that...
>
> there is not only php-code in this field, but theres also html.
> is eval() working for that to?
including code then do:
eval("?>$page<?php");
Kevin Thorpe Guest
-
Pedro Graca #5
Re: php+mysql-driven webpage
Kevin Thorpe wrote:
I couldn't get eval to work with my example :(> IIRC eval starts in <?php context so if you have a complete webpage
> including code then do:
> eval("?>$page<?php");
So I made a function to eval my example :)
Hope it can help the OP
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
<code language="php" length="41 lines">
<?php
$db_value = '<b><?php echo phpversion(); ?></b>
foobar
<?php $x=date("Y-m-d"); ?>
foobaz
<?php echo $x; ?>
foobar again';
echo code_eval($db_value);
echo "\n--------\n";
eval("?>$db_value<?php"); ## error here!
function code_eval($__STO_string) {
## __STO_ (security through obscurity)
// isolate all code between the php tags
preg_match_all('/<\?php(.*)\?>/Us', $__STO_string, $__STO_php_code);
// eval each one of them and store each evaluation in an array
$__STO_evaled = array();
foreach ($__STO_php_code[1] as $__STO_sub_code) {
ob_start();
eval($__STO_sub_code);
$__STO_evaled[] = ob_get_clean();
}
// replace code and php tags by their result
$__STO_i = 0;
$__STO_string_evaled = $__STO_string;
while (isset($__STO_evaled[$__STO_i])) {
$__STO_string_evaled = preg_replace('/<\?php(.*)\?>/Us',
$__STO_evaled[$__STO_i],
$__STO_string_evaled,
1);
++$__STO_i;
}
// return the eval'd chunk
return $__STO_string_evaled;
}
?>
</code>
--
--= my mail address only accepts =--
--= Content-Type: text/plain =--
--= Size below 10K =--
Pedro Graca Guest
-
Chung Leong #6
Re: php+mysql-driven webpage
Another way to do this is through remote include(). Use an URL in
place of a file path like this:
include("http://localhost/db_php_code.php?criteria=something");
In db_php_code.php, connect to the database and echo the code.
"Michael Volk" <micha_volk@t-online.de> wrote in message news:<bq78pn$leq$04$1@news.t-online.com>...> hi!
> thx for that...
>
> there is not only php-code in this field, but theres also html.
> is eval() working for that to?
>
> its a complete site with html AND php-code stored.
>
> thx,
> Michael
>
>
> "Pedro Graca" <hexkid@hotpop.com> schrieb im Newsbeitrag
> news:bq78lk$1vfe93$1@ID-203069.news.uni-berlin.de...> > Michael Volk wrote:> >> > > I have php-code stored in a mysql-table.
> > > How do i run this code?
> > >
> > > if i echo it, i see the code, but how do i run it?
> > eval() it.
> >
> > [url]http://www.php.net/eval[/url]
> > --
> > --= my mail address only accepts =--
> > --= Content-Type: text/plain =--
> > --= Size below 10K =--Chung Leong Guest



Reply With Quote

