This is a discussion on Easy PHP question within the PHP Language forums, part of the PHP Programming Forums category; Im trying to send a variable via GET to a php script like so: <a href="process.php?...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Im trying to send a variable via GET to a php script like so:
<a href="process.php?id=test & test">Link</a> Leaving spaces is no problem, but the & symbol (ampersand) cannot be displayed to the screen. I want it to show "test & test". Instead it displays just "test" without the rest following it. Can anyone tell me how to display the whole variable passed to process.php? TIA Rob |
|
|||
|
On 12 Sep 2003 17:01:24 -0700, gojuka@si.rr.com (Robert) wrote:
>Im trying to send a variable via GET to a php script like so: > ><a href="process.php?id=test & test">Link</a> > >Leaving spaces is no problem, but the & symbol (ampersand) cannot be >displayed to the screen. I want it to show "test & test". Instead it >displays just "test" without the rest following it. In a URL, & is one of the separator characters (; being the other); so you have urlencode it for it to be part of a value within a URL. <a href="process.php?id=<?php echo urlencode('test & test')?>">Link</a> It'll come out as: <a href="process.php?id=test+%26+test">Link</a> >Can anyone tell me how to display the whole variable passed to >process.php? And then & is special in HTML. You must encode it as & in any output. echo htmlspecialchars($_GET['id']); -- Andy Hassall (andy@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk) Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space) |