Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    200
    Thanks
    27
    Thanked 2 Times in 2 Posts

    $_REQUEST issues

    Hello,

    I am trying to get a category from a url using $_REQUEST. This all works fine until there is an & in the category title e.g main.php?cat=nicky & php

    Then it only returns nicky (the half before the &). I've tried using & but it makes no difference.

    I'd usually pass an id in the url (if I had to pass something) to eliminate these problems, but I'm working on someone elses software and this is how they have done it.

    Is there any way you can suggest to get the whole value including the &. I'm assuming as spaces work ok it's just the & that is a problem.

    Thanks,

    Nicky

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    Just create a form(having method="post") with one text and and a submit filed. Then type a string having an &, say a&b and then submit it. You'd see how the form handles it, by looking the url.

    (Adding another input control to the form would show you, how it interprets & in the url)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder mic2100's Avatar
    Join Date
    Feb 2006
    Location
    Scunthorpe
    Posts
    562
    Thanks
    15
    Thanked 28 Times in 27 Posts
    try use "%26" (without the quotes) for the "&" and use "%20" for the spaces.

    cat=nicky%20%26%20php

    If you are unsure about wot the put u can use
    PHP Code:
    echo urlencode("&");
    echo 
    urldecode("%26"); 
    to find the values u are after

    the problem you are having is because the url string uses & to separate the named values.
    Last edited by mic2100; 12-03-2008 at 12:39 PM.


  •  

    Posting Permissions

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