Jump to content

Recommended Posts

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?

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/71299-_get-changes-the-argument/
Share on other sites

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']);
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.