Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Is ',' bad in the url?

Reply
Thread Tools

Is ',' bad in the url?

 
 
FFMG
Guest
Posts: n/a
 
      12-08-2007

Hi,

I want to use a separator in some queries in the URL

http://www.example.com/?k=1,2,3

It all works fine but the ',' is converted to the html '%2C', (I use
php URLencode, http://php.net/urlencode).

Why is that? I see many sites that don't convert the ',' in their
links, (sky.com for example).
Should I not bother converting comas as well?

What would be a better way of listing items in the URL?

Thanks

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=22996

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

 
Reply With Quote
 
 
 
 
J.O. Aho
Guest
Posts: n/a
 
      12-08-2007
FFMG wrote:
> Hi,
>
> I want to use a separator in some queries in the URL
>
> http://www.example.com/?k=1,2,3
>
> It all works fine but the ',' is converted to the html '%2C', (I use
> php URLencode, http://php.net/urlencode).


The function do convert the string in the same way as it would be if it had
been posted as application/x-www-form-urlencoded.

The %XX don't change how the data is handled, just looks differently and works
sometimes a lot better than not urlencode the string.


> What would be a better way of listing items in the URL?


Use an array instead of one variable.


--

//Aho
 
Reply With Quote
 
 
 
 
FFMG
Guest
Posts: n/a
 
      12-08-2007

J.O. Aho;107610 Wrote:
> FFMG wrote:
> > Hi,
> >
> > I want to use a separator in some queries in the URL
> >
> > http://www.example.com/?k=1,2,3
> >
> > It all works fine but the ',' is converted to the html '%2C', (I use
> > php URLencode, http://php.net/urlencode).

>
> The function do convert the string in the same way as it would be if it
> had
> been posted as application/x-www-form-urlencoded.
>
> The %XX don't change how the data is handled, just looks differently
> and works
> sometimes a lot better than not urlencode the string.
>


Like I said, it all works fine.
My problem is purely from a cosmetic point of view, it looks broken.

J.O. Aho;107610 Wrote:
>
> Use an array instead of one variable.
>


Do you mean http://www.example.com/?k[0]=1&k[1]=2 ?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=22996

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      12-08-2007
FFMG wrote:

> It all works fine but the ',' is converted to the html '%2C', (I use php
> URLencode, http://php.net/urlencode).


The PHP urlencode() function is a little overcautious. It encodes
virtually any non-alphanumeric character in the URL, even though many
would be perfectly safe to leave unencoded.

If you prefer your commas to be unencoded, then I suggest writing your
own replacement for urlencode. It's not difficult.

If you're using PHP 5.3+ with namespaces, then you can even name your
function "urlencode()" too, so that you don't need to go through all your
files replacing calls to urlencode() with my_urlencode().

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 23:40.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      12-08-2007
FFMG wrote:
> J.O. Aho;107610 Wrote:
>> FFMG wrote:
>>> Hi,
>>>
>>> I want to use a separator in some queries in the URL
>>>
>>> http://www.example.com/?k=1,2,3
>>>
>>> It all works fine but the ',' is converted to the html '%2C', (I use
>>> php URLencode, http://php.net/urlencode).

>> The function do convert the string in the same way as it would be if it
>> had
>> been posted as application/x-www-form-urlencoded.
>>
>> The %XX don't change how the data is handled, just looks differently
>> and works
>> sometimes a lot better than not urlencode the string.
>>

>
> Like I said, it all works fine.
> My problem is purely from a cosmetic point of view, it looks broken.
>
> J.O. Aho;107610 Wrote:
>> Use an array instead of one variable.
>>

>
> Do you mean http://www.example.com/?k[0]=1&k[1]=2 ?


In ASP, at least,

http://www.example.com/?k=1&k=2&k=3

will result in Request("k") being an array with three values. Perhaps in
PHP too.
 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      12-08-2007
Harlan Messinger wrote:

> In ASP, at least,
>
> http://www.example.com/?k=1&k=2&k=3
>
> will result in Request("k") being an array with three values. Perhaps in
> PHP too.


The equivalent in PHP is:

http://www.example.com/?k[]=1&k[]=2&k[]=3

k=1&k=2&k=3 will result in $_GET['k'] being '3'. Of course, one can
always manually parse $_SERVER['QUERY_STRING'] to get the full list out.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 3:15.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/1...tunes-sharing/
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
integer >= 1 == True and integer.0 == False is bad, bad, bad!!! rantingrick Python 44 07-13-2010 06:33 PM
Bad media, bad files or bad Nero? John Computer Information 23 01-08-2008 09:17 PM
ActiveX apologetic Larry Seltzer... "Sun paid for malicious ActiveX code, and Firefox is bad, bad bad baad. please use ActiveX, it's secure and nice!" (ok, the last part is irony on my part) fernando.cassia@gmail.com Java 0 04-16-2005 10:05 PM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 12 02-23-2005 03:28 AM
24 Season 3 Bad Bad Bad (Spoiler) nospam@nospam.com DVD Video 0 02-19-2005 01:10 AM



Advertisments