Connecting Tech Pros Worldwide Help | Site Map

Parse problem.

mark
Guest
 
Posts: n/a
#1: Jul 16 '05
I have a problem that php removes the + char. When i type this in the
adres bar:
http://www.test.com/test.php?t=a+b

and when i do a echo in the php page the + char is gone? I also tried
to use the javascript escape function before redirecting but that
won't work eather.

Can someone explein what i'm doing wrong? And how to post a + char ina
other way or something like that..

thanks
mark
Bert
Guest
 
Posts: n/a
#2: Jul 16 '05

re: Parse problem.


On 18 Jul 2003 02:46:50 -0700, m_z_r@hotmail.com (mark) wrote:
[color=blue]
>I have a problem that php removes the + char. When i type this in the
>adres bar:
>http://www.test.com/test.php?t=a+b
>
>and when i do a echo in the php page the + char is gone? I also tried
>to use the javascript escape function before redirecting but that
>won't work eather.
>
>Can someone explein what i'm doing wrong? And how to post a + char ina
>other way or something like that..
>
>thanks
>mark[/color]

I found this in the php-manual:

To encode a '+' (plus) symbol so it ends up as '+' when decoded
automatically by PHP, you have to do this:

rawurlencode(rawurlencode("+"));

If you just call rawurlencode() once, the resulting "%2B" is converted
to '+' before '+' symbols are converted to spaces, which is not very
useful.

Give it a try...
B.

Jim Dabell
Guest
 
Posts: n/a
#3: Jul 16 '05

re: Parse problem.


mark wrote:
[color=blue]
> I have a problem that php removes the + char. When i type this in the
> adres bar:
> http://www.test.com/test.php?t=a+b
>
> and when i do a echo in the php page the + char is gone?[/color]

You are not sending a + character to the script. You are sending a space to
the script. Special characters like spaces get encoded so that they are
safe for transport across HTTP. Your script is seeing the data you sent
it, not the raw encoded form.

When you create links with non-hardcoded data in the query string, make sure
you run urlencode() over the data you are supplying:

echo("http://www.example.com/test.php?t=" . urlencode($data));

(Also, somebody owns the test.com domain, example.com is reserved
specifically for this purpose).

[color=blue]
> I also tried
> to use the javascript escape function before redirecting but that
> won't work eather.[/color]

Client-side scripting is unreliable. Plenty of people have javascript
unavailable, for all sorts of reasons.


--
Jim Dabell

Closed Thread