PDA

View Full Version : Parsing ampersand in same query


thehappyappy
11-19-2010, 05:52 PM
This might sounds like a simple problem but try as I may I can't figure it out. I want to be able to get an ampersand from the url. I'm sending people to a new page depending on which category they've selected. The problem is that some of the categories have an & in them which is being interpreted and a separate string.

I know the easiest solution would be to remove the ampersands before they're sent and replace them with 'and' or '+' but I don't have access to the database to be able change this.

Also not all of the urls will have an ampersand but they will all come from the same place. So for example one might be: http://www.tdomain.net/?listings.asp&wapl_listing=7&category=Games%20&%20Fun&svi=2882392&NMSS2892=0uckh54u3safknjakjsbhfnn786t6g2fkm1 and the other would be http://www.tdomain.net/?listings.asp&wapl_listing=7&category=Movies&svi=2882392&NMSS2892=0uckh54u3safknjakjsbhfnn786t6g2fkm1

Both times it would only be the 'category' query I would want (so Games & Fun in the first and then Movies in the second)

I've looked every where but can't find anythign that has helped.

By the way if it makes any difference the ASP is being output to XML, but I thought I'd mention it anyway.

Thansk for any help.

Old Pedant
11-19-2010, 06:52 PM
You don't show how you are creating those URLs in your ASP program.

But, in general, the answer is Server.URLEncode() or (not as good, but usually works) Escape()

That is, your code might be something like:

...
url = "http://www.tdoamin.net/listings.asp?category=" & Server.URLEncode(RS("category"))

If you want more help, show real code. It's hard to write code blind.