Solved

ASP "Quotes" Problem

Posted on 1998-11-04
4
156 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
[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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

696 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