Closed Thread
Results 1 to 5 of 5

Thread: mysql_real_escape_string

  1. #1
    mikelbring is offline Programmer
    Join Date
    Jul 2008
    Location
    Nebraska
    Posts
    118
    Rep Power
    0

    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. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Jordan Guest

    Re: mysql_real_escape_string

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

  4. #3
    mikelbring is offline Programmer
    Join Date
    Jul 2008
    Location
    Nebraska
    Posts
    118
    Rep Power
    0

    Re: mysql_real_escape_string

    Realize the Web Web services and design.

  5. #4
    Jordan Guest

    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.

  6. #5
    Join Date
    Jul 2006
    Location
    Amherst, New York, United States
    Posts
    6,277
    Blog Entries
    26
    Rep Power
    20

    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

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. warning in mysql_real_escape_string
    By newphpcoder in forum PHP Development
    Replies: 1
    Last Post: 05-10-2011, 06:25 AM
  2. problem in htmlentities() and mysql_real_escape_string()
    By newphpcoder in forum PHP Development
    Replies: 2
    Last Post: 05-08-2011, 09:03 PM

Tags for this Thread

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