www.webdeveloper.com
Results 1 to 2 of 2

Thread: Executing PHP code from mysql

  1. #1
    Join Date
    Oct 2007
    Posts
    154

    Executing PHP code from mysql

    Hi,

    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.

    Thanks!

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,322
    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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

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



Recent Articles