Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - <textarea> and single quotes
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Topic Closed<textarea> and single quotes

 Post Reply Post Reply
Author
fatcity101 View Drop Down
Newbie
Newbie


Joined: 11 November 2003
Status: Offline
Points: 5
Direct Link To This Post Topic: <textarea> and single quotes
    Posted: 10 June 2004 at 10:22am

Hello all,

I have an ASP page with a <textarea> on it that is posting the contents of the <textarea> into an Access database. When the form on the page is processed, the following code is used before putting the information into the database:

var mytextarea = Request("mytextarea")+"";

mytextarea = mytextarea.replace("'", "''");

This is supposed to deal with the single quotes before the INSERT query The problem is that it only works if mytextarea has one quote. If there are more than one quote in mytextarea, I receive the following error:

[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression ''Isn''t it funny this doesn't work'

Anyone know how to replace multiple instances of single quotes?

Thanks in advance

Back to Top
dj air View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 April 2002
Location: United Kingdom
Status: Offline
Points: 3627
Direct Link To This Post Posted: 11 June 2004 at 2:01pm

use this example

mytextArea = Replace(mytextArea , "value you want to change", "value you want to change it to", 1, -1, 1)

you can leave the second "" like "" which will replace the other value to nothing. resulting in deleting the value.

hope that helps

Back to Top
Semikolon View Drop Down
Senior Member
Senior Member


Joined: 09 September 2003
Location: Norway
Status: Offline
Points: 1718
Direct Link To This Post Posted: 12 June 2004 at 5:13pm
Replace(myTextArea, "'", "&#39;")

this will replace the single quote ' with &#39; which will display as '
Back to Top
Bluefrog View Drop Down
Senior Member
Senior Member


Joined: 23 October 2002
Location: Korea, South
Status: Offline
Points: 1701
Direct Link To This Post Posted: 14 June 2004 at 11:50am

It's amazing how many encodings can't keep basic standards. The web is a mess.

Someday we'll have something that actually works.

(I'm referring to how different encodings slaughter the single and double quote characters.)

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.