Re: Problems with quotes in URL
| From: | Petre Agenbag | Date: | Wed, 18 Jun 2003 12:00:49 +0000 |
| Subject: | Re: Problems with quotes in URL | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-151967@lists.php.net to get a copy of this message | ||
OK, this is the URL that my code produces after it get's the my_var from
the mysql table.
my_var in the table is => whatever whatever "whatever whatever"
So I do a select and I do a $my_var = $myrow['my_var'] (after all the
proper mumbo jumbo about the $myrow = mysql_fetc_assoc...etc.)
I then do a $my_var = addslashes($my_var)as well as $my_var =
urlencode($my_var).
Then I simply create a link like so:
echo '<a
href="page.php?my_var='.$my_var.'&next_var=blabla">link</a>';
Clicking on that link displays exactly the following in the browser's
URL location:
page.php?my_var=whatever+whatever++%5C%22whatever+whatever%5C%22&next_var=blabla
And now, on page.php
If I do an
echo stripslashes($my_var);
I get exactly this:
whatever whatever \
What am I missing?
On Wed, 2003-06-18 at 11:18, Chris Hayes wrote:
> >IN a mysql db, I would have a name like :[ whatever "whatever" ]
> >
> >I do a select on the table and then echo the name on a page, as well as
> >add it to a url:
> >
> >page.php?myvar=$myvar
> >
> >where $myvar contains the [ whatever "whatever" ]
> >
> >Now, when I try to echo $myvar on the page.php, I don't get the entire
> >story.
> >
> >I tried to addslashes() before the url line, I tried urlencode() and
> >htmlspecialchars, all causes an echo of $myvar on the page.php page to
> >only display whatever , or, whatever \ but NEVER, whatever "whatever"
>
>
> What does your link in which 'whatever' is look like ?
> How do you test to see what is in the variable?
>
>
> This does the job for me:
>
> <?PHP
>
> if ($_GET['x']=='')
> {$i='whatever "Whatever"';
> echo '<a
> href="get.php?x='.urlencode($i).'">link</a>';
>
> }
> else
>
> echo 'x is '.urldecode($_GET['x']);
>
> ?>
>
> and the url looks
> like:http://www.XXXXX.nl/get.php?x=whatever+%22Whatever%22
>
>
>
>
>
>