what is the need of addcslashes and addslashes?

Discussion in 'PHP' started by bhuppi890109, Apr 24, 2011.

  1. #1
    hi i am newbie in php. i have a query.
    when we can apply the '\' manually. then what is the need of addcslashes and addslashes in php.
     
    bhuppi890109, Apr 24, 2011 IP
  2. vetrivel

    vetrivel Peon

    Messages:
    147
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,
    How do you add slashes manually for the user generated datas.
    say for example:
    If someone enters vetri'p as user data .how will handle it and insert it directly to the database will leads to malfunctioning.

     
    vetrivel, Apr 25, 2011 IP
  3. bhuppi890109

    bhuppi890109 Member

    Messages:
    1,337
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    48
    #3
    yes exactly..thanks vetrivel
     
    bhuppi890109, Apr 25, 2011 IP
  4. subdivisions

    subdivisions Well-Known Member

    Messages:
    1,021
    Likes Received:
    40
    Best Answers:
    1
    Trophy Points:
    145
    #4
    It's better to use mysql_real_escape_string() if you're doing it to sanitize MySQL data, as that fixes a couple other MySQL-specific things.
     
    subdivisions, Apr 25, 2011 IP
  5. fast-dir

    fast-dir Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    addslashes() can prevent your code from some basic sql injection attacks.
     
    fast-dir, Apr 27, 2011 IP
  6. gnomee

    gnomee Greenhorn

    Messages:
    25
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    An example how i'm using this.. mysql_escape_string(strip_tags(htmlspecialchars(some code)))
     
    gnomee, Apr 27, 2011 IP
  7. lioncub5

    lioncub5 Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    yes, addslashes is deprecated- we have better alternatives now.
     
    lioncub5, Apr 30, 2011 IP