Connecting Tech Pros Worldwide Help | Site Map

Parse problem.

  #1  
Old July 16th, 2005, 11:50 PM
mark
Guest
 
Posts: n/a
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
  #2  
Old July 16th, 2005, 11:50 PM
Bert
Guest
 
Posts: n/a

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.

  #3  
Old July 16th, 2005, 11:50 PM
Jim Dabell
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
DateTime.Parse problem with Time Format using period =?Utf-8?B?c2lwcHl1Y29ubg==?= answers 4 February 7th, 2007 07:15 PM
The lib email parse problem... 叮叮当当 answers 19 August 31st, 2006 04:35 AM
a html parse problem cheng answers 1 July 19th, 2005 02:38 AM