Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Backslash shows up in textarea content save to file?

    I am eading from a text area and then writing that content to a file. When I then read that file and display its contents, any single quote character appears with a backslash in front of it, e.g., "don't" appears as "don\'t".

    Does anyone know why this happens and what steps can be taken to pevent it?

    G

  • #2
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,040
    Thanks
    10
    Thanked 92 Times in 90 Posts
    it happens as PHP automatically escapes any special chars (this annoys many people) although magic_quotes can be disabled in the php.ini they rarely are (and partially for good reasons) but you can alter that with ini_set() at runtime if you wish www.php.net/ini_set

    easiest way around is, when you display the data, instead of

    echo $string;

    echo stripslashes($string);
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    firepages,

    Thanks. I stripslashed $HTTP_POST_VARS and that got the job done.

    G


  •  

    Posting Permissions

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