Page 1 of 1

PHP codes from MySQL database?

Posted: Tue Nov 01, 2005 12:35 am
by Covenant
Can I store PHP scripts/coding in a row in a table in a MySQL database and have that run on a certain page?

i.e. a mysql row contains

Code: Select all

<?php
            echo "Hi man! You rule!";
            $he_sure_rules="Y";
            ?>
a page, stuff.php, contains some sort of function (this is what i'm asking, i don't know what this function, if any, IS)

Code: Select all

<?php

   /* some sort of function here */

   ?>
and the page would output

Code: Select all

Hi man! You rule!
of course.

Would that be the eval() function? Or something else? Is it even possible?

Posted: Tue Nov 01, 2005 12:51 am
by feyd
you can do it yes.. eval() is what would be needed, however using eval() is not recommended for a number of reasons we have already gone over several times here on the boards. Instead, storing the code in a file is safer (with the proper precautions and things taken) and often far easier to implement securly.

Posted: Tue Nov 01, 2005 12:51 am
by Jenk
Why not ust store the scripts in flat files?

Posted: Tue Nov 01, 2005 9:59 am
by BDKR
Jenk wrote:Why not ust store the scripts in flat files?
The better question is why do you need to store the scripts? What are you doing that requires this as a solution?