View Full Version : $_REQUEST issues

12-03-2008, 12:43 PM

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.



12-03-2008, 01:35 PM
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)

12-03-2008, 01:36 PM
try use "%26" (without the quotes) for the "&" and use "%20" for the spaces.


If you are unsure about wot the put u can use

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.