Solved

ASP "Quotes" Problem

Posted on 1998-11-04
4
153 Views
Last Modified: 2013-12-25
Im setting up a web-based form which will gather a product description, and then store it in an Access database using ASP.

A few folks have used quotes ("'s) in their descriptions.  These quotation marks within the description, when read into another web-based editing form, chop the description at the first ".

Is there any way around this without having the users enter &qout in place of quotation marks?
0
Comment
Question by:chilcote
  • 2
4 Comments
 
LVL 28

Accepted Solution

by:
sybe earned 150 total points
ID: 1856105
1.
Before storing the description into the database, you should "escape" the quote: replace it with two times the quote. Use the replace function for that:

EscapedString = REPLACE(String,CHR(39),CHR(39)&CHR(39))

2. Use Server.HTMLEncode(string) before storing the data in your database. All code will then be encoded into HTML.

3. Use Server.URLEncode before storage in the database (and URLDecode when displaying)


0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856106
chilcote:

I think you't having problems with a " and not with '
In that case you can use a small VB Script function in your 'asp' which takes a string argument and returns another string after replacing " with " which you can display in a form or in HTML. Here it is.

function replaceQuote(str)
  if Instr(str, Chr(34)) then
    str = Replace(str, Chr(34), """)
  end if
  replaceQuote = str
end function

if 'aVariable" is a string containing "s then the statement
  aVariable = replaceQuote(aVariable)
will replace "s with "
0
 
LVL 1

Expert Comment

by:rajgn
ID: 1856107
In the above case you need not bother before storing the data into database
0
 

Author Comment

by:chilcote
ID: 1856108
Much obliged.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

911 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now