SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    parsing a variable with spaces as a link

    Is there any way to pass a variable with spaces in it as a link (ie GET data). For example

    www.domain.com/review.php?title=and then he said

    sort of thing.

    I can't do any PHP or anything like that with the link unfortunatly, a unchangeable script generates the link.

    It works without doing anything in IE5 but not Netscape 4. Any ideas?

  2. #2
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would have thought that any browser IE, NS4.*, et al, would send that as:
    Code:
    www.domain.com/review.php?title=and%20then%20he%20said
    And then you can use urldecode() or rawurldecode() to put the white spaces back into the string in your script. I can never remember the difference between those two functions, but I seem to use rawurlencode and rawurldecode for some reason?

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nope, unfortunatly NS4 really does not do this. try clicking on this link with NS4

    http://www.sitepointforums.com/index...hen he shouted and see what happens

  4. #4
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, the link works for me...

  5. #5
    SitePoint Evangelist
    Join Date
    Feb 2000
    Location
    England
    Posts
    568
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, the link works but does it put
    %20
    between the words. If not, as it dosen't in NS4 for me, only the first word of the variable title is accessible from the PHP script.

  6. #6
    SitePoint Wizard
    Join Date
    Jul 2001
    Location
    The Netherlands
    Posts
    2,617
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It does put %20 between the words, meaning the whole phrase is accessable as being the keyword title. I am using IE 5.5 of 6.0 by the way, I can't tell since it loads to quickly !

  7. #7
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Chris just run your variable through urlencode() or rawurlencode() before appending it to the query string.


    PHP Code:
    $var urlencode($var); //puts %20 in
    //or
    $var rawurlencode($var); //puts + in 

    If you hard coding the link just put them in there in place of the spaces.
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •