PHP codes from MySQL database?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Covenant
Forum Newbie
Posts: 15
Joined: Sun Oct 02, 2005 3:30 pm

PHP codes from MySQL database?

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

Why not ust store the scripts in flat files?
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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?
Post Reply