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 4 of 4
  1. #1
    New Coder
    Join Date
    Dec 2009
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    stripslashes .... thing. Removing \ from multiple chars

    So. If I type:
    The quick brown fox was too freakin' lazy to jump over the lazy dog.
    I get:
    The quick brown fox was too freakin\' lazy to jump over the lazy dog.
    (I know the new PHP stops this, but I can't upgrade)
    So if I use the command to remove slashes I get rid of all slashes (which I don't want to do), so I tried str_replace
    PHP Code:
    $str3 = array("\\"", "'", "\\\");
    $str4 = array("", "", "");
    $str = str_replace($str3,$str4,$_POST['
    str]); 
    But that obviously didn't work. So how would I replace \" or \' or \\ with nothing?

    (in the php above, it removed my single quote thing. it looked like this without and spaces: \ \ ' )

  • #2
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Try:
    PHP Code:
    $str get_magic_quotes_gpc()?stripslashes($_POST['str']):$_POST['str']; 

  • #3
    Regular Coder
    Join Date
    Mar 2006
    Posts
    238
    Thanks
    3
    Thanked 37 Times in 37 Posts
    Or you could try to disable magic_quotes_gpc via .htaccess (provided your HTTP server is Apache). You could try to add the following like to .htaccess for it:
    Code:
    php_flag magic_quotes_gpc Off
    Of course before doing any changes in .htaccess, make a backup copy of your original .htaccess somewhere.

  • #4
    New Coder
    Join Date
    Dec 2009
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Thank you SKDevelopment. That worked like a charm.


  •  

    Posting Permissions

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