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
Solved

ASP "Quotes" Problem

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
pure CSS responsive image rotation for Ecommerce Product Page images 4 47
When should I use a controller? 3 40
"Go Fund Me" type plugin 5 24
asp Google Map 2 23
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
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…
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…

791 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