Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

value with & not being sent correctly by querystring 1

Status
Not open for further replies.

vasox56

Technical User
May 8, 2007
75
GB
im having trouble sending a value to another page using querystring..

the value is:

Code:
Elephant & Castle

when i load this value from my database and display it on my first page, it displays correctly using the following:

Code:
<%= rs("placeNAME")%>

i try to send that string to another page as Postcode using this script

Code:
<form action="online-booking1.asp?Price=<%=sTempVar & "163;" & trim(rs("salPRICE"))%>&amp;Postcode=<%= rs("placeNAME")%>&amp;FCar=Saloon" method="post">

on my second page i receive the value like so:
Code:
zpostcode = Request.QueryString("Postcode")

and display the value using
Code:
<%=(zpostcode)%>

the problem is.. Elephant & Castle is only displaying as Elephant on the new page

can anyone see why it is cutting off the rest of the string.

thanks
 
you will need to encode the string properly, because the ampersand marks a connection between querystring parameters.

however you're setting your variable, you'll first need to encode it properly.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
how do you do that

i know that % can sometimes be used as a space.. or something like that

not sure though
 
the replacement for & is [tt]&amp;[/tt].

some languages have encoding functions you should look into. JavaScript has the urlencode/urldecode functions, ASP has similar.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
>i know that % can sometimes be used as a space.. or something like that

that's escape "%20" = (space) "%26"=&
 
ok.. i realise that i will need to encode the variable before it gets sent so the value remains consistent.

i presume it will be in this part..

Code:
<form action="online-booking1.asp?Price=<%=sTempVar & "163;" & trim(rs("salPRICE"))%>[b]&amp;Postcode=<%= rs("placeNAME")%>[/b]&amp;FCar=Saloon" method="post">

the string seems to display correctly as
<%= rs("placeNAME")%>

but are you telling me that before that is sent.. i have to include something that tells it to watch out for & characters

i dont know how to do that.
 
i have just realised that the second page may not be receiving the string properly..

if this is the case.. what can i add to this statement to grab everything..

Code:
zpostcode = Request.QueryString("Postcode")
 
feherke is correct,

SPACE %20
# %23
$ %24
% %25
& %26
/ %2F
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
@ %40
[ %5B
\ %5C
] %5D
^ %5E
` %60
{ %7B
| %7C
} %7D
~ %7E



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top