RB101 Posted September 30, 2007 Share Posted September 30, 2007 This seems like it should be a very elementary thing to do, but I'm a beginner at PHP. I'm passing an argument on a url which may contain "+" characters, and/or quoted strings, like this: ...../myprog.php?rt=abc+def+"st uv" When I retrieve rt using $_GET, it replaces the + signs with blanks, and escapes the quotes with backslashes, so I end up with: abc def \"st uv\" (And then, when I put the string through mysql_real_escape_string, it gets further modified, to: abc def \\\"st uv\\\" ) Since I have to match the string to a DB field that has the original argument in it (abc+def+"st uv"), this just doesn't work. What's the correct way of obtaining the unmodified argument? Quote Link to comment https://forums.phpfreaks.com/topic/71299-_get-changes-the-argument/ Share on other sites More sharing options...
Barand Posted October 1, 2007 Share Posted October 1, 2007 use urlencode() prior to putting it in the querystring. use stripslashes() prior to mysql_real_escape_string() <?php $txt = 'abc+def+"st uv"'; $rt = urlencode($txt); echo "<a href='?rt=$rt'>LINK</a><br/>"; if (isset($_GET['rt'])) { echo "rt is : ", stripslashes($_GET['rt']); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71299-_get-changes-the-argument/#findComment-358726 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.