Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 8 of 8
  1. #1
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    I'm assuming at some point in my contact form process something has converted all the 's to \'s and "s to \"s and so on (was it at the POST stage?)

    How do I change them back? is there a function like htmlspecialchars()?
    tekp :cheeky: tekponline.com

  2.  

  3. #2
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    It's probably idiotic magic quotes, which cause more problems than they solve.

    http://us3.php.net/manual/en/security.magicquotes.php

    As for removing them: [phpfunction]stripslashes[/phpfunction]
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  4. #3
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Ah thank you

    Out of curiosity, at which stage would this happen? When the form was posted? And why does it come up with three slashes, not just one? ( \\\' not \' ) Is it because it first escapes the ' and then the \ twice? So it does it three times...?

    Edit: And when I perform the function on \\\' it returns \'?
    tekp :cheeky: tekponline.com

  5. #4
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    Magic quotes automatically escapes incoming GET/POST data before it even reaches your script. So, they get added between when the user clicks Submit and your form's submission script runs.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  6. #5
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Ah thanks

    Do you know why it returns \' when I perform the function on \\\'? Did it just get rid of the "\\" and I have to do the function again? Is there an easier way to do this other than just:

    PHP Code:
    $var stripslashes($var);
    $var stripslashes($var); 
    ?
    tekp :cheeky: tekponline.com

  7. #6
    Senior Member filburt1's Avatar
    Join Date
    Jul 2002
    Location
    Maryland, US
    Posts
    11,774
    Member #
    3
    Liked
    21 times
    \\ is an escaped backslash, so \\\' becomes \', which is what was literally typed.

    The only lame solution I can think of is to stripslashes() in a loop, comparing the result of stripslashes to the iteration before. Once there's no change, break the loop.
    filburt1, Web Design Forums.net founder
    Site of the Month contest: submit your site or vote for the winner!

  8. #7
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    http://uk2.php.net/manual/en/function.str-replace.php

    The order of the arguments are replace_this_char, with_this_char, in_this_string

    PHP Code:
    $var str_replace("\", "", "hello world"); 
    Edit: filburt1 posted as I did..

  9. #8
    Senior Member tekp's Avatar
    Join Date
    Jan 2004
    Location
    A small village near a small city near a small cit
    Posts
    918
    Member #
    4667
    Liked
    1 times
    Ah right, thanks bfsog, I didn't think of that ^-^

    Thanks to all!
    tekp :cheeky: tekponline.com


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:19 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com