mcrypt help please

Discussion in 'PHP' started by JEET, Aug 25, 2008.

  1. #1
    Hi,
    I am trying to encode strings, and it works fine. The problem is that when I try to add it to mysql, I use
    addslashes(). Now when I do stripslashes() and try to decode the string, the value is completely different. If I do not use addslashes and stripslashes, it works fine, but won't go in database most of the times.
    What to do? Please help. Should I change the key etc...
    Thanks :)
     
    JEET, Aug 25, 2008 IP
  2. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Are you using mysql_real_escape_string before storing it in the DB?
     
    The Universes, Aug 26, 2008 IP
  3. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #3
    Yes, I'm using it. But I'm also using stripslashes when getting the string from DB. Won't this get me the original string?
    Thanks
     
    JEET, Aug 26, 2008 IP
  4. Dman91

    Dman91 Peon

    Messages:
    46
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well i think when you insert the string into the db via mysql_real_escape_string it will be escaped already so you need not use stripslashes.
     
    Dman91, Aug 27, 2008 IP