+ Reply to Thread
Results 1 to 5 of 5

Thread: mysql_real_escape_string

  1. #1
    Programmer mikelbring is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Nebraska
    Posts
    115

    mysql_real_escape_string

    I have read a few different places that doing mysql_real_escape_string is not all that safe. I am wondering what are more practices I can take to make my code secure from MySQL or other attacks.

    My Security function:
    Code:
    public function clean(&$value){
        
            if (
    ini_get('magic_quotes_gpc')) $value stripslashes($value); 
            
            
    $value mysql_real_escape_string($value);
        
        } 
    Realize the Web Web services and design.

  2. #2
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: mysql_real_escape_string

    mysql_real_escape_string is probably the safest way to cleanse tainted data directed at a MySQL database.

  3. #3
    Programmer mikelbring is an unknown quantity at this point
    Join Date
    Jul 2008
    Location
    Nebraska
    Posts
    115
    Realize the Web Web services and design.

  4. #4
    Administrator Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan is a name known to all Jordan's Avatar
    Join Date
    Nov 2005
    Location
    Hendersonville, NC
    Posts
    24,556
    Blog Entries
    97

    Re: mysql_real_escape_string

    The first article (excellent read) doesn't say anything bad against mysql_real_escape_string directly. It does state that if you escape all post/get quotes you can mess up data. Basically, you should only use mysql_real_escape_string at data aimed for mysql (and if you are not using mysql you shouldn't use this unless you are willing to make a DB connection).

    For article #2 I didn't read the whole thing but skipped directly to section #3 which states:

    The well known remedy to that is to escape all variables that will be included in the dynamic query with mysql_real_escape_string(). Example 2 shows that the same attacks no longer work.
    It is basically recommending that you need to escape all strings aimed at SQL to prevent SQL injection.

  5. #5
    Co-Administrator John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John is a glorious beacon of light John's Avatar
    Join Date
    Jul 2006
    Age
    21
    Posts
    5,885
    Blog Entries
    25

    Re: mysql_real_escape_string

    another method that should be used in conjunction with escaping is to use regular expressions to make sure the data that goes into the database is the data you expect
    Posted via CodeCall Mobile

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

     

Bookmarks

Bookmarks

     
        Algorithms and Data Structures

        Java tutorials

        Algorithms Forum

Posting Permissions

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