SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2008
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Your PHP MySQL functions template

    I know many people use a single functions.php file to include all of their "usual" functions very handy when coding.

    For example, to keep anything going into the database input clean:

    Code:
    function db_input($string) {
        return addslashes($string);
      }
    Would you like to share your thoughts on a functions template that you use universally across all of the projects you are working on?

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Throwing all your "usual" functions into a single utility file is generally considered bad practice.

    As is using addslashes() to clean database input. It is neither correct nor sufficient for placing data in a MySQL query. Use mysql_real_escape_string() or you can still end up with input that breaks the query getting put into it.

  3. #3
    SitePoint Wizard silver trophy kyberfabrikken's Avatar
    Join Date
    Jun 2004
    Location
    Copenhagen, Denmark
    Posts
    6,157
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Why would you rather type db_input than addslashes ?

  4. #4
    Made with a Mac! philm's Avatar
    Join Date
    Sep 2001
    Location
    Portsmouth, UK
    Posts
    735
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Awww go easy on the poor fella...


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
  •