SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    When I use the mail() function to send content inserted into a form, the apostrophs in the content are automatically preceeded by a backslash. Why does this happen and how can I avoid it.

    I'm also having trouble inserting text into a database that contains apostrophs using a script I've created. I'm hoping that the question above will answer this as well.

    Thanks in advance !
    Sincerely,

    Eirik Johansen
    Netmaking AS

  2. #2
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To avoid problems use the command
    PHP Code:
    $data addslashes($data
    (You can check it here) before storing information in the database.
    When you want to extract the information from your database use
    PHP Code:
    $data stripslashes($data

  3. #3
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Also, if you have magic_quotes on the ', " and \ are escaped with a backslash automatically.

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To further Paul S, since you have no data coming from a database it is obvious to me that you have magic_quotes on in the php.ini file and that is why you are getting apostrophes escaped by a backslash, as Paul said all you would need to do in your case is run

    $str = stripslashes($str);

    Before sending the mail.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by freddydoesphp
    To further Paul S, since you ...
    Hey Freddy I guess you mean Eirik (he's the one who started this thread)
    Paul

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I meant to further your answer. Not responding directly to you.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  7. #7
    E-business guru Eirik's Avatar
    Join Date
    Nov 2000
    Location
    Oslo, Norway
    Posts
    413
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks to you both, guys. It was first and foremost the stripslashes() function I was looking for, but it's nice to know the "reverse" function as well.
    Sincerely,

    Eirik Johansen
    Netmaking AS

  8. #8
    Happy Holidays !! Paul S's Avatar
    Join Date
    Mar 2001
    Location
    Mexico
    Posts
    1,287
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Eirik,

    you're welcome

    Freddy,

    I see


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
  •