Date:  06/03/2011 03:18:03 AM Msg ID:  004290
From:  Steven Gruner Thread:  004288
Subject:  Re: Is there a way to easily parse a query?
Ah, yes, that is what I was looking for. Thanks!
 
However since I'm never going to use & anyway and since I wrote a few substr() parses already, I'll just leave it the way it is because it works fine.
I'll keep that in mine to use  request.querystring should any of my queries have to use ampersand in them. For what I wrote right now, it doesn't so it won't cause an issue (for now at least...lol).
Sent by FoxWeb Support on 06/02/2011 03:11:51 PM:
Are you parsing the URL of the currently executing request? How are you getting access to the URL? If this is the case, you can simply use the Request.QueryString method to gain access to each name/value pair in the query string. If on the other hand you are trying to parse a string that you constructed in your program, you will need to use VFP's string manipulation functions, such as substr.
 
The example you have below does not seem correct to me. In this particular example the ampersand (&) has been URLEncoded to "%26". This should not be the case. Ampersands should only be URLEncoded if they are part of the name or the value. In this case, it is used as a delimiter between 2 name/value pairs. Here's an example, illustrating correct encoding of ampersands:
 
In this example the query string will contain two query string variables:
 
  • type: "sales"
  • company_name: "barnes & noble"
 
http://someserver.com/program.fwx?type=sales&company_name=barnes%20%26%20noble
 
Spaces can also be URL-encoded as "+" characters:
 
http://someserver.com/program.fwx?type=sales&company_name=barnes+%26+noble 
 
In both examples above you can see that one of the ampersands (the one separating the type and company_name query string variables) was not encoded, while the one in the company name was. If the ampersand in the name was not encoded, the receiving server would treat the second part of the name as a separate query string variable. 
FoxWeb Support Team
support@foxweb.com email
Sent by Steven Gruner on 06/02/2011 01:59:18 PM:
I'm using a url like http://www.mysite.com/map.htm?db=la2do%26uid=MMNOP
So far I'm just using substr() to parse each parameter which works fine. But
I'm wondering two things:
 
1) Is there an easier way than having to substr() each parameter?
 
2) Why does the ampersand not parse correctly if it's not url encoded?