Results 1 to 4 of 4

Thread: Storing PHP code in MYSQL database? Good idea or bad?

  1. #1
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Storing PHP code in MYSQL database? Good idea or bad?

    Hi

    I want to know if storing php code in mysql database is a good idea or bad idea? From the form where the code is actually saved is the admin area where no normal user can access and also it gets inserted using the POST method, so I am guessing an attack is likely to be easy. I just wanted to know as far as the security goes how much risk is involved? What is a good way to storing PHP code in the database?

    Thanks

  2. #2
    Join Date
    Mar 2007
    Posts
    54
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Anyone?

  3. #3
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    if you are storing it there for the sake of storing it there, then no!
    if its being stored as strictly data, then sure go ahead.

    you should by all means store data in your database rather than hard coding page after page after page, however your php should be in their own php file. if you are just looking for better security. Use some scripts that will sanitize the data going to and from the client / user.

    there are many many tutorials on the web, use some keywords like php stanitize clean mysql

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Probably a very bad idea.

    Unless the code itself is actually dynamic, and being edited from the admin control panel, then this is extremely inefficient.

    You would need to use eval(), and that is slow.

    If you need to store a statement or two, that's fine.

    Generally, you should be able to use various statements to make this work, mostly ifs. Just use a keyword from the database, perhaps as a function name.

    It would be much more efficient to store the data in a php file and include it, most of the time.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

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