Link to home
Start Free TrialLog in
Avatar of bschwarting
bschwarting

asked on

request.querystring then replace syntax

why doesn't this work?

ADDR1 = Request.Querystring("val20")
ADDR1 = Replace(  ADDR1,"#","" )
Avatar of b0lsc0tt
b0lsc0tt
Flag of United States of America image

bschwarting,

Response.Write ADDR1 to confirm that it contains a pound sign before you try to replace.  Then use a response.write for the results.  What does happen?  Are you getting an error or just no change to the value?

Let me know if you have any questions or need more information.

b0lsc0tt
Avatar of bschwarting
bschwarting

ASKER

the # sign is still there, that's why I'm asking.  when it has the # sign, it messes up the rest of the data below it.  when it's gone, it fixes the issue.
Change the replace to the line below.  The pound sign is changed in the querystring to %23.

ADDR1 = Replace(ADDR1, "%23", "")
Take the space out before ADDR1 in the Replace function:
 ADDR1 = Replace(ADDR1,"#","")
SOLUTION
Avatar of Scripter25
Scripter25

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i'm lost on this one.  i've tried all the above, and the # won't go away.  i've tried all these variants:

ADDR1 = Replace(ADDR1,"#","")
ADDR1 = Replace( ADDR1,"#","" )
ADDR1 = Replace(ADDR1, "%23", "")
ADDR1 = Replace( ADDR1, "%23", "" )
ADDR1 = Replace(ADDR1, "#", "%23")
ADDR1 = Replace( ADDR1, "#", "%23" )

no luck.  here is the code from the previous page where it gets posted, maybe this will help:

<td>
<a href="gas_print.asp?val1=<%= x_MBRSEP %>&val2=<%= x_NAME %>&val3=<%= x_RATE %>&val4=<%= x_CLASS %>&val5=<%= x_TELEPHONE %>&val6=<%= x_LOCATION %>&val7=<%= x_METER %>&val8=<%= x_READDATE %>&val9=<%= x_READDATE %>&val10=<%= x_NBRDAYSSVC %>&val11=<%= x_PREVMTRREAD %>&val12=<%= x_METERREAD %>&val13=<%= x_KWH %>&val14=<%= x_FUEL2 %>&val15=<%= x_APPLNBR %>&val16=<%= x_DUEDATE %>&val17=<%= x_MISCCHG %>&val18=<%= x_CYCLE %>&val19=<%= x_BILLDATE %>&val20=<%= x_ADDR1 %>&val21=<%= x_ADDR2 %>&val22=<%= x_ADDR3 %>">Print</a>      
</td>
Try this

ADDR1 = Replace(Request.QUeryString("val20"),"%23","")

IF that does not work then try
ADDR1 = Replace(Request.QUeryString("val20"),"#","")


Also look at the query string in the address bar and look for val20 check to see what it says for that and then put that value in here so we can see maybe there is something with what you have for your data..




 
same thing:

&val20=#%20100%20CHEROKEE%20ST%20SUITE%20410&val21
I have one more that you can try.  If it doesn't work then I have something we can use to maybe identify what character is used.  By the way, what browser are you using?  Have you tried another type of browser?

ADDR1 = Replace(ADDR1, Chr(35), "")
b0lsc0tt
 maybe on to something with that
Also if you do not need the # sign at all on this page why dont you try to remove the # from the variable prior to placing into the querystring on the first page?
that didn't work either.

i'm using firefox and IE6 to test.

let me give a little more info, maybe this will help.

two pages are being used:
#1 = memberno_list.asp ** has this code: <a href="gas_print.asp?val1=<%= x_MBRSEP %>&val2=....)
#2 = gas_print.asp ** has this code: ADDR1 = Replace(ADDR1,"#","")

If I use the replace code on page #1, it works fine (cleanup the text before I passit to the URL), but it won't work on page#2 (after it's in the URL).  The reason i'm trying to get this working on page#2 is because I would have to update up to 50 pages each time I go through a routine to make this print function work. (long story)  If i can get the replace code to work in page#2, i don't ever have to update the 50+ pages each time in #1.

since the text is already passed to the url, i would think i could manipulate it before it gets to the field that I response.write it out, and fix my problem.  easier said than done i guess.
Scripter25, ha, i guess we were writing at the same time, read above...
Is the # sign always in the first charater in the string? If so try this
ADDR1 = RIGHT(ADDR1, LEN(ADDR1)-1)
The syntax may be a bit off
no, the # is all over the address.
Only 50 pages??  Why not just update them? :D

This problem isn't rare.  I have seen issues like this that can be a little work to figure out.  Best way to do it is before, like you already mentioned, but it would definitely be a lot of work in this case.  The code below should break tell us the Ansi code for each character (formatted as code[character],).  You could also copy the information in some Hex editor program to get he information.  The code below is a modified version of code by Acperkins in https://www.experts-exchange.com/questions/21949345/replace-funny-box-character-from-string.html.

Dim i
For i = 1 to Len(ADDR1)
   Response.Write Asc(Mid(ADDR1, i, 1)) & "[" & Mid(ADDR1, i, 1) & "], "
Next
What is the "code" for the # character?
b0lsc0tt,

this is what i got:

50[2], 57[9], 48[0], 53[5], 32[ ], 76[L], 73[I], 66[B], 82[R], 65[A], 82[R], 89[Y], 32[ ], 76[L], 78[N],
Comment from b0lsc0tt
Date: 09/15/2006 11:41AM PDT

What is the "code" for the # character?

huh?
Those results show that ADDR1 contained "2905 LIBRARY LN" (no quotes).  If you response.write ADDR1 then do you see the leading # sign?  If not, then where do it appear?

Instead of using ADDR1 in the code I provided try using Request.Servervariables("QUERY_STRING").  That should show us the whole querystring so it may be long.  Look for the section that has val20 and what is after it?  Hopefully you will see the characters before the address and not just the address that we got the last time.
URL encoding has been mentioned already above, but has it been tried?

On the previous page where it gets posted, try this:

<%
Dim URLParams

URLParams = "?val1=" & x_MBRSEP
URLParams = URLParams & "&val2="& x_NAME
URLParams = URLParams & "&val3=" & x_RATE
URLParams = URLParams & "&val4=" & x_CLASS
URLParams = URLParams & "&val5=" & x_TELEPHONE
URLParams = URLParams & "&val6=" & x_LOCATION
URLParams = URLParams & "&val7=" & x_METER
URLParams = URLParams & "&val8=" & x_READDATE
URLParams = URLParams & "&val9=" & x_READDATE
URLParams = URLParams & "&val10=" & x_NBRDAYSSVC
URLParams = URLParams & "&val11=" & x_PREVMTRREAD
URLParams = URLParams & "&val12=" & x_METERREAD
URLParams = URLParams & "&val13=" & x_KWH
URLParams = URLParams & "&val14=" & x_FUEL2
URLParams = URLParams & "&val15=" & x_APPLNBR
URLParams = URLParams & "&val16=" & x_DUEDATE
URLParams = URLParams & "&val17=" & x_MISCCHG
URLParams = URLParams & "&val18=" & x_CYCLE
URLParams = URLParams & "&val19=" & x_BILLDATE
URLParams = URLParams & "&val20=" & x_ADDR1
URLParams = URLParams & "&val21=" & x_ADDR2
URLParams = URLParams & "&val22=" & x_ADDR3
URLParams = Server.URLEncode(URLParams)
%>  

<td>
<a href="gas_print.asp<%=URLParams%>">Print</a>    
</td>
nope, looks like it's just not going to work on my second page.  guess i'll just have to use my find/replace and hope for the best!
b0lsc0tt,

what hex editor are you using?
>>>>>>>>>>>>>>>>>>>>>>>>>>>
Comment from b0lsc0tt
Date: 09/15/2006 11:41AM PDT
      Comment       Accept

What is the "code" for the # character?
>>>>>>>>>>>>>>>>>>>>>>>>>>>

b0lsc0tt,
not sure what planet i was one, but i just figured out what you were asking.  the code to convert it to ansi stops when it sees the # sign.  so it never gives me the "code" for the # symbol.

i just now re-read your other response (The code below should break tell us the Ansi code for each character (formatted as code[character],)) and figured out how you got text out of all those jumbled #'s and letters...(haha)

anway, to reiterate, the ansi code stops when it see's a #, and gives no code.

that is a sweet trick for future use though.

thanks,
bschwarting
example of what happens:

ansi code generated with this text in the field (100 CHEROKEE ST SUITE # 410)
49[1], 48[0], 48[0], 32[ ], 67[C], 72[H], 69[E], 82[R], 79[O], 75[K], 69[E], 69[E], 32[ ], 83[S], 84[T], 32[ ], 83[S], 85[U], 73[I], 84[T], 69[E], 32[ ], 32[ ],
I'm glad you are back on this planet and my comments make a little more sense. :D  I agree that the code is pretty sweet and worth keeping handy.

Did you also try using Request.Servervariables("QUERY_STRING") instead of ADDR1?  Did it still end at the # sign and not show the end of val20 or the other val's after it?

Thanks in advance for your reply and the additional info.
same thing w/ Request.Querystring("val20")

49[1], 48[0], 48[0], 32[ ], 67[C], 72[H], 69[E], 82[R], 79[O], 75[K], 69[E], 69[E], 32[ ], 83[S], 84[T], 32[ ], 83[S], 85[U], 73[I], 84[T], 69[E], 32[ ], 32[ ],
No.  I may have misunderstood but I want you to use the following to show the WHOLE querystring.

Dim i
For i = 1 to Len(Request.Servervariables("QUERY_STRING"))
   Response.Write Asc(Mid(Request.Servervariables("QUERY_STRING"), i, 1)) & "[" & Mid(Request.Servervariables("QUERY_STRING"), i, 1) & "], "
Next

If that is what you used then I apologize but it seems that you used Request.Querystring("val20").  The results will probably be REALLY long but may give us an idea of the problem.

Can you provide a URL for me to test?  I can't remember if you mentioned this already or if I have asked but did you test on other browsers or computers?

Thanks!
IE and firefox

here is the end of it, same thing, stops after the #

118[v], 97[a], 108[l], 50[2], 48[0], 61[=], 49[1], 48[0], 48[0], 37[%], 50[2], 48[0], 67[C], 72[H], 69[E], 82[R], 79[O], 75[K], 69[E], 69[E], 37[%], 50[2], 48[0], 83[S], 84[T], 37[%], 50[2], 48[0], 83[S], 85[U], 73[I], 84[T], 69[E], 37[%], 50[2], 48[0], 37[%], 50[2], 48[0],

value 20 = ADDR1 = 100 CHEROKEE ST SUITE # 410
So you also saw all of the other name/value pairs before that section you copied in your comment?  Did you get val21 or val22?  Can you see more of the querystring in your browser's address bar?

It has been a little while since we started this and I didn't find this information while quickly reading the previous comments but please forgive me if I overlooked it.  Is this info coming from a form?  User/visitor input?  If not what is the source?  If it is a form try changing the method to POST.  Does that fix the problem?  Although the earlier comments and discussion didn't seem like the problem was related to length limits on the querystring that may explain why it is completely cut off, especially if you don't get the final 2 name/values either.

Are there actually 2 spaces after SUITE in the address?
there are actually 42 variables, i just removed some for simplicity sake.

no matter where i put the # symbol in the data, it always stops at it (#), whether it's val1 or val42.

the # is currently in val20, so no, i don't get val21 or val22 or beyond...

yes, i see all the data in the browsers address bar.

yes, there are 2 spaces after SUITE in the address

data is posted via a form with the POST method, using this:

<a href="gas_print.asp?val1=<%= x_MBRSEP %>&val2=<%= x_NAME %>&val3=<%= x_RATE %>&val4=<%= x_CLASS %>&val5=<%= x_TELEPHONE %>&val6=<%= x_LOCATION %>&val7=<%= x_METER %>&val8=<%= x_READDATE %>&val9=<%= x_READDATE %>&val10=<%= x_NBRDAYSSVC %>&val11=<%= x_PREVMTRREAD %>&val12=<%= x_METERREAD %>&val13=<%= x_KWH %>&val14=<%= x_FUEL2 %>&val15=<%= x_APPLNBR %>&val16=<%= x_DUEDATE %>&val17=<%= x_MISCCHG %>&val18=<%= x_CYCLE %>&val19=<%= x_BILLDATE %>&val20=<%= x_ADDR1 %>&val21=<%= x_ADDR2 %>&val22=<%= x_ADDR3 %>&val23=<%= x_BILLTYPE %>&val24=<%= x_SVCADDR %>&val25=<%= x_CHG1 %>&val26=<%= x_ZIP %>&val27=<%= x_READSEQ %>&val28=<%= x_OTHERACCTNBR %>&val29=<%= x_NET %>&val30=<%= x_TAX %>&val31=<%= x_LOCALTAX %>&val32=<%= x_FRANCHISETAX %>&val33=<%= x_GROSSTAX %>&val34=<%= x_OTHERTAX %>&val35=<%= x_ENERGY %>&val36=<%= x_FUEL %>&val37=<%= x_WEATHER %>&val38=<%= x_SLCHG %>&val39=<%= x_OTHERAMT1 %>&val40=<%= x_OTHERAMT2 %>&val41=<%= x_OTHERAMT3 %>&val42=<%= x_INTRATE %>">Print</a>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
looks like this isn't possible, thanks for all the assistance.
Your welcome!  I was really hoping that we could get it to work somehow but I agree with your last comment.  Thank you for the grade, the points and the fun question.
I know this is a bit late but this may help others out in the future


' Decode the urlEncoded Query String Referer data
Function URLDecode(str)

str = uCase(str)
str = Replace(str, "%20", " ")
str = Replace(str, "%21", "!")
str = Replace(str, "%22", Chr(34))
str = Replace(str, "%23", "#")
str = Replace(str, "%24", "$")
str = Replace(str, "%25", "%")
str = Replace(str, "%26", "&")
str = Replace(str, "%27", "'")
str = Replace(str, "%28", "(")
str = Replace(str, "%29", ")")
str = Replace(str, "%2A", "*")
str = Replace(str, "%2B", "+")
str = Replace(str, "%2C", ",")
str = Replace(str, "%2D", "-")
str = Replace(str, "%2E", ".")
str = Replace(str, "%2F", "/")
str = Replace(str, "%30", "0")
str = Replace(str, "%31", "1")
str = Replace(str, "%32", "2")
str = Replace(str, "%33", "3")
str = Replace(str, "%34", "4")
str = Replace(str, "%35", "5")
str = Replace(str, "%36", "6")
str = Replace(str, "%37", "7")
str = Replace(str, "%38", "8")
str = Replace(str, "%39", "0")
str = Replace(str, "%3A", ":")
str = Replace(str, "%3B", ";")
str = Replace(str, "%3C", "<")
str = Replace(str, "%3D", "=")
str = Replace(str, "%3E", ">")
str = Replace(str, "%3F", "?")
str = Replace(str, "%40", "@")
str = Replace(str, "%41", "A")
str = Replace(str, "%42", "B")
str = Replace(str, "%43", "C")
str = Replace(str, "%44", "D")
str = Replace(str, "%45", "E")
str = Replace(str, "%46", "F")
str = Replace(str, "%47", "G")
str = Replace(str, "%48", "H")
str = Replace(str, "%49", "I")
str = Replace(str, "%4A", "J")
str = Replace(str, "%4B", "K")
str = Replace(str, "%4C", "L")
str = Replace(str, "%4D", "M")
str = Replace(str, "%4E", "N")
str = Replace(str, "%4F", "O")
str = Replace(str, "%50", "P")
str = Replace(str, "%51", "Q")
str = Replace(str, "%52", "R")
str = Replace(str, "%53", "S")
str = Replace(str, "%54", "T")
str = Replace(str, "%55", "U")
str = Replace(str, "%56", "V")
str = Replace(str, "%57", "W")
str = Replace(str, "%58", "X")
str = Replace(str, "%59", "Y")
str = Replace(str, "%5A", "Z")
str = Replace(str, "%5B", "[")
str = Replace(str, "%5C", "\")
str = Replace(str, "%5D", "]")
str = Replace(str, "%5E", "^")
str = Replace(str, "%5F", "_")
str = Replace(str, "%60", "`")
str = Replace(str, "%61", "a")
str = Replace(str, "%62", "b")
str = Replace(str, "%63", "c")
str = Replace(str, "%64", "d")
str = Replace(str, "%65", "e")
str = Replace(str, "%66", "f")
str = Replace(str, "%67", "g")
str = Replace(str, "%68", "h")
str = Replace(str, "%69", "i")
str = Replace(str, "%6A", "j")
str = Replace(str, "%6B", "k")
str = Replace(str, "%6C", "l")
str = Replace(str, "%6D", "m")
str = Replace(str, "%6E", "n")
str = Replace(str, "%6F", "o")
str = Replace(str, "%70", "p")
str = Replace(str, "%71", "q")
str = Replace(str, "%72", "r")
str = Replace(str, "%73", "s")
str = Replace(str, "%74", "t")
str = Replace(str, "%75", "u")
str = Replace(str, "%76", "v")
str = Replace(str, "%77", "w")
str = Replace(str, "%78", "x")
str = Replace(str, "%79", "y")
str = Replace(str, "%7A", "z")
str = Replace(str, "%7B", "{")
str = Replace(str, "%7C", "|")
str = Replace(str, "%7D", "}")
str = Replace(str, "%7E", "~")
str = Replace(str, "%io", "h")
str = Replace(str, "%A0", " ")
str = Replace(str, "%A1", "¡")
str = Replace(str, "%A2", "¢")
str = Replace(str, "%A3", "£")
str = Replace(str, "%A4", "¤")
str = Replace(str, "%A5", "¥")
str = Replace(str, "%A6", "¦")
str = Replace(str, "%A7", "§")
str = Replace(str, "%A8", "¨")
str = Replace(str, "%A9", "©")
str = Replace(str, "%AA", "ª")
str = Replace(str, "%AB", "«")
str = Replace(str, "%AC", "")
str = Replace(str, "%AD", "­")
str = Replace(str, "%AE", "®")
str = Replace(str, "%AF", "¯")
str = Replace(str, "%B0", "°")
str = Replace(str, "%B1", "±")
str = Replace(str, "%B2", "²")
str = Replace(str, "%B3", "³")
str = Replace(str, "%B4", "´")
str = Replace(str, "%B5", "µ")
str = Replace(str, "%B6", "")
str = Replace(str, "%B7", "·")
str = Replace(str, "%B8", "¸")
str = Replace(str, "%B9", "¹")
str = Replace(str, "%BA", "º")
str = Replace(str, "%BB", "»")
str = Replace(str, "%BC", "¼")
str = Replace(str, "%BD", "½")
str = Replace(str, "%BE", "¾")
str = Replace(str, "%BF", "¿")
str = Replace(str, "%C0", "À")
str = Replace(str, "%C1", "Á")
str = Replace(str, "%C2", "Â")
str = Replace(str, "%C3", "Ã")
str = Replace(str, "%C4", "Ä")
str = Replace(str, "%C5", "Å")
str = Replace(str, "%C6", "Æ")
str = Replace(str, "%C7", "Ç")
str = Replace(str, "%C8", "È")
str = Replace(str, "%C9", "É")
str = Replace(str, "%CA", "Ê")
str = Replace(str, "%CB", "Ë")
str = Replace(str, "%CC", "Ì")
str = Replace(str, "%CD", "Í")
str = Replace(str, "%CE", "Î")
str = Replace(str, "%CF", "Ï")
str = Replace(str, "%D0", "Ð")
str = Replace(str, "%D1", "Ñ")
str = Replace(str, "%D2", "Ò")
str = Replace(str, "%D3", "Ó")
str = Replace(str, "%D4", "Ô")
str = Replace(str, "%D5", "Õ")
str = Replace(str, "%D6", "Ö")
str = Replace(str, "%D7", "×")
str = Replace(str, "%D8", "Ø")
str = Replace(str, "%D9", "Ù")
str = Replace(str, "%DA", "Ú")
str = Replace(str, "%DB", "Û")
str = Replace(str, "%DC", "Ü")
str = Replace(str, "%DD", "Ý")
str = Replace(str, "%DE", "Þ")
str = Replace(str, "%DF", "ß")
str = Replace(str, "%E0", "à")
str = Replace(str, "%E1", "á")
str = Replace(str, "%E2", "â")
str = Replace(str, "%E3", "ã")
str = Replace(str, "%E4", "ä")
str = Replace(str, "%E5", "å")
str = Replace(str, "%E6", "æ")
str = Replace(str, "%E7", "ç")
str = Replace(str, "%E8", "è")
str = Replace(str, "%E9", "é")
str = Replace(str, "%EA", "ê")
str = Replace(str, "%EB", "ë")
str = Replace(str, "%EC", "ì")
str = Replace(str, "%ED", "í")
str = Replace(str, "%EE", "î")
str = Replace(str, "%EF", "ï")
str = Replace(str, "%F0", "ð")
str = Replace(str, "%F1", "ñ")
str = Replace(str, "%F2", "ò")
str = Replace(str, "%F3", "ó")
str = Replace(str, "%F4", "ô")
str = Replace(str, "%F5", "õ")
str = Replace(str, "%F6", "ö")
str = Replace(str, "%F7", "÷")
str = Replace(str, "%F8", "ø")
str = Replace(str, "%F9", "ù")
str = Replace(str, "%FA", "ú")
str = Replace(str, "%FB", "û")
str = Replace(str, "%FC", "ü")
str = Replace(str, "%FD", "ý")
str = Replace(str, "%FE", "þ")
str = Replace(str, "%FF", "ÿ")
str = Replace(str, "+", " ")

    URLDecode = lCase(str)
End Function
added the function above, and tried this:

ADDR1 = Request.Querystring("val20")
ADDR1 = URLDecode(ADDR1)

still no go.
sorry but it is a good function for future reference....

You just have one of those Bermuta Triangle issues

The world may never know
no doubt it's a good function, it just didn't work for my situation.
function kept for future reference though, thanks!