Re: [PHP-DB] RE: Storing Code in a db?

2001-07-03 Thread Szii

XML would be perfect for this.  You store the XML in the database (usually a
BLOB/CLOB/Long VARCHAR/etc)
and your script pulls the XML out, and parses it there.

You can have a set of input forms written in PHP which'll generate the XML
for you.

Of course, this assumes some knowledge of XML, but theoretically you could
do it with
a flat file format (like comma/tilde delimited) and just store the string
in the database.

It's trivial to write a PHP script that generates PHP directly...

$str = echo \hi!\;; // you can use single-quotes if you're more
comfortable with them
$str .= echo \Done!\;; // note that it's got a ; INSIDE the
string...it's PHP in there, after all
eval($str);

If you wanted to pre-generate it, I don't see any reason why you couldn't
addslashes()
the code, and INSERT it that way.  Pull it back out, stripslashes() it, and
eval() it.

Voila!

-Szii

- Original Message -
From: Mark McCray [EMAIL PROTECTED]
To: olinux [EMAIL PROTECTED]; php-db [EMAIL PROTECTED]
Sent: Monday, July 02, 2001 5:54 PM
Subject: Re: [PHP-DB] RE: Storing Code in a db?


 Here was the application I was thinking of creating for my organization.
 We wanted to make an online survey tool.  Where you can create a survey,
 with sections, possibly subsections, questions, and acceptable answers.

 It's easy enough to create this stuff each and every time, but it's
 ridiculously tedious.

 So why not make an application that does it automatically.

 So we were thinking that you kind of have to define the different types of
 questions/answers that can be used in the survey. For example, a straight
 text field, multiline text field, 5 radio button selection, 5 option
 pull-down, Yes/No radio button, checkboxes, etc...

 So in defining the types of questions/answers, we thought it might be cool
 to define each type of answer and the code that goes along with generating
 it.  So when defining the survey questions, you tell it that the question
 has a 3 radio button answer, and the system would pull code from the
 database to help generate the question/answer html dynamically when
someone
 goes to the survey.

 I know you could store the functions as includes, but just thought it
would
 be cool if people could store the code in the database, because there
might
 just be an answer type that I haven't yet thought to program.

 Marky



 on 7/1/01 2:34 PM, olinux at [EMAIL PROTECTED] wrote:

 
  Couldn't you just store the php commands as a txt file and then use a
SSI
  [server side include]?
 
  olinux
 
  It would be very convenient to be able to store PHP (or any other
server
  side code) in a database, then retrieve and execute it.
 
  I store a lot of website content with embedded HTML commands in a
  database.
  Being able to store PHP code in the database as well would be very
  convenient.
  Lets think about something:
  if we put some code in a field and then we out the of code from code put
in
  temporal file and then include in our principal code :)))
 
  but i have a doubt eval funcion we work with functions printf,  echo? i
  don't think so.
 
 
 
  The only way I can think of doing it would involve a lot of very messy
  parsing out of the php commands. I expect that would take way to much
  processing time. I don't imagine that would work for entire functions
  either. Maybe just individual PHP commands.
 
  Any ideas
 
  Thanks! Rita
 
 
 
  _
  Do You Yahoo!?
  Get your free @yahoo.com address at http://mail.yahoo.com
 
 


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] RE: Storing Code in a db?

2001-07-02 Thread Mark McCray

Here was the application I was thinking of creating for my organization.
We wanted to make an online survey tool.  Where you can create a survey,
with sections, possibly subsections, questions, and acceptable answers.

It's easy enough to create this stuff each and every time, but it's
ridiculously tedious.

So why not make an application that does it automatically.

So we were thinking that you kind of have to define the different types of
questions/answers that can be used in the survey. For example, a straight
text field, multiline text field, 5 radio button selection, 5 option
pull-down, Yes/No radio button, checkboxes, etc...

So in defining the types of questions/answers, we thought it might be cool
to define each type of answer and the code that goes along with generating
it.  So when defining the survey questions, you tell it that the question
has a 3 radio button answer, and the system would pull code from the
database to help generate the question/answer html dynamically when someone
goes to the survey.

I know you could store the functions as includes, but just thought it would
be cool if people could store the code in the database, because there might
just be an answer type that I haven't yet thought to program.

Marky



on 7/1/01 2:34 PM, olinux at [EMAIL PROTECTED] wrote:

 
 Couldn't you just store the php commands as a txt file and then use a SSI
 [server side include]?
 
 olinux
 
 It would be very convenient to be able to store PHP (or any other server
 side code) in a database, then retrieve and execute it.
 
 I store a lot of website content with embedded HTML commands in a
 database.
 Being able to store PHP code in the database as well would be very
 convenient.
 Lets think about something:
 if we put some code in a field and then we out the of code from code put in
 temporal file and then include in our principal code :)))
 
 but i have a doubt eval funcion we work with functions printf,  echo? i
 don't think so.
 
 
 
 The only way I can think of doing it would involve a lot of very messy
 parsing out of the php commands. I expect that would take way to much
 processing time. I don't imagine that would work for entire functions
 either. Maybe just individual PHP commands.
 
 Any ideas
 
 Thanks! Rita
 
 
 
 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com
 
 


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]