Connecting Tech Pros Worldwide Help | Site Map

Parse problem.

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 16th, 2005, 10:50 PM
mark
Guest
 
Posts: n/a
Default Parse problem.

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, 10:50 PM
Bert
Guest
 
Posts: n/a
Default 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, 10:50 PM
Jim Dabell
Guest
 
Posts: n/a
Default 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

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.