Page 1 of 1

how can i pass string with "&" in url use $_g

Posted: Wed Feb 26, 2003 1:02 pm
by EXDev
I'm trying to pass a string with an "&" in the middle from url, but when i use $_GET["name"] to retrive the value, it cuts off whatever append to the "&" of the string
so its like when using http://aaa.com?name=abc&abc in the url bar,
$_GET["name"] will only return abc instead of abc&abc
anyone know why and how to fix it
thanks

Posted: Wed Feb 26, 2003 1:08 pm
by daven
you need to use the HTML code for ampersands. Try encoding the URL with htmlspecialchars(). It should work correctly then

Posted: Wed Feb 26, 2003 2:05 pm
by EXDev
thanks
just figure out what the problems is. when the string pass thur url, the broswer consider the "&" as "variable separator", like ...com?name=abc&pass=123.
so when i try to pass the string "abc&abc" by ...com?name=abc&123, the broswer thinks the first variable is name and second is 123, so when i use $_GET["name"], it only gives me abc.

Posted: Wed Feb 26, 2003 2:45 pm
by daven
Exactly. You cannot have things like ampersands (&), question marks (?), or other such things in a query string, as HTML uses them for variable declaration.