Results 1 to 2 of 2

Thread: Executing PHP code from mysql

  1. #1
    Join Date
    Oct 2007

    Executing PHP code from mysql


    Does anybody know another method of executing php code from a mysql result.

    Is the eval() function the only way?

    If so, is using it for a cms safe since only the webmaster will be using it?

    Any information regarding this issue is greatly appreciated.


  2. #2
    Join Date
    Aug 2004
    I'm a believer in "If eval() is the answer, you're probably asking the wrong question." (Attributed to the creator of PHP.)

    Why do you want/need PHP code in the database in the first place? A better understanding of that might lead us to a better solution.

    In general, I'd rather store any/all code in PHP files, perhaps as function definitions that can be require()'d. Then if for some reason you need to use info from the database to control what code gets executed, you would, for example, just store a function name or parameter or whatever in the DB, and use that to control what code gets executed or how it gets executed.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center