Solved

ASP "Quotes" Problem

Posted on 1998-11-04
4
154 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

831 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