?
Solved

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

Posted on 2003-03-20
9
Medium Priority
?
3,091 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 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