Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Request.QueryString translates plus sign into a space?!?!

Posted on 2003-03-20
9
Medium Priority
?
3,098 Views
Last Modified: 2012-03-15
My first page contains an e-mail address from a database and an edit link. The edit link takes you to the edit page with a single text field containing the e-mail address. I get that e-mail from the previous page by passing it into the URL - "www.myurl.com?edit=somename@someurl.com" and then I use Request.QueryString. The problem is that some valid e-mail addresses contain a plus sign in the name. That plus sign is translated into a space when it appears in the text field. Any suggestions?
0
Comment
Question by:bjrcreations
  • 4
  • 4
9 Comments
 
LVL 11

Accepted Solution

by:
ASPGuru earned 100 total points
ID: 8177103
email = "some+name@someurl.com"
editlink = "www.myurl.com?edit=" & Server.URLEncode(email)


ASPGuru
0
 
LVL 11

Expert Comment

by:L00M
ID: 8177122
email = "some+name@someurl.com"
editlink = "www.myurl.com?edit=" & Server.URLEncode(email)

on the second page, you may be wondering how to "UN Urlencode" that variable. To do so, put in your asp page, at the bottom or wherever, the following function:

%>
<script language=JavaScript RUNAT=SERVER>
// This function decodes the any string
// that's been encoded using URL encoding technique
function URLDecode(psEncodeString)
{
  // Create a regular expression to search all +s in the string
  var lsRegExp = /\+/g;
  // Return the decoded string
  return unescape(String(psEncodeString).replace(lsRegExp, " "));
}
</script>
<%

Note, that is NOT within the <%%>.

You can then, from anywhere in the ASP code, make a call like:

Response.Write URLDecode(Request.Querystring("edit"))
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 8177153
LOOM, what are you talking about??
Querystring gets decoded automatically by ASP, when received through the querystring... no need to decode it manually...

ASPGuru
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 11

Expert Comment

by:L00M
ID: 8177233
ASPGuru,
 My bad! You are correct. I use Server.URLEncode quite a bit to store data into databases. So, when I retrieve the data, I use the above function to decode the data. Works great, and you don't have to worry about invalid characters in the data, such as an unexpected single quote.

bjrcreations,
 Sorry about that.
0
 
LVL 3

Author Comment

by:bjrcreations
ID: 8177236
Thanks ASPGuru - that was exactly what I needed!
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 8177265
@LOOM
a single quote isn't invalid... you just need to escape it with a second single quote...

name="O'Mealey"
name=replace(name,"'","''")

sql="select * from tab where name='" & name & "'"


ASPGUru
0
 
LVL 11

Expert Comment

by:L00M
ID: 8177506
Unless you are using MySQL, in which case you have to escape it with a '\'. So, to make it compatible with all DB's, I just use the URLEncode.
0
 
LVL 11

Expert Comment

by:ASPGuru
ID: 8177630
i usually use a function which looks like this:

function sqlText(t)
  sqlText = replace(t,"'","''")
end function

then you just need to replace at one place...

ASPGuru
0
 
LVL 11

Expert Comment

by:L00M
ID: 8177676
I have a similar function as well. Anyway, we're off topic and trading knowledge we both know about. CIAO for now.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question