Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 5th, 2006, 01:59 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default Apostrophe in a textarea

Hi,
How do I get round the problem of an (') apostrophe in a textarea?
Thanks.

Reply With Quote
  #2 (permalink)  
Old June 5th, 2006, 02:57 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Can you be more specific, what is the problem and do you have an example?

Cheers,

Chris

Reply With Quote
  #3 (permalink)  
Old June 5th, 2006, 03:57 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

When someone enters a word, say it's or I'm the form is not processed. I get an error message. If written without the apostrophe then the data is accepted.
From that I am ssuming, it's the apostrophe 'bug'.

Reply With Quote
  #4 (permalink)  
Old June 5th, 2006, 04:08 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sounds like you may be doing something with sql on you subsequent page, what is the error message and code on the line causing the error?

Reply With Quote
  #5 (permalink)  
Old June 5th, 2006, 04:06 PM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression ''I'm testing')'.
/TheMiddlePath/matconfirm.asp, line 41




Reply With Quote
  #6 (permalink)  
Old June 6th, 2006, 02:51 AM
Friend of Wrox
 
Join Date: Jul 2003
Location: , , United Kingdom.
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you replace any single quotes in your strings with a pair of single quotes in your SQL statement, everything should work fine, e.g.
Code:
INSERT INTO myTableName(myFieldName) VALUES('I''m testing');
HTH,

Chris

Reply With Quote
  #7 (permalink)  
Old June 6th, 2006, 01:06 PM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you.
But the word I'm testing was put into the 'textarea' on the form and the error came up. Other users may put other words that contain an apostrophe.

This textarea sends info to a MEMO field in ACCESS.

how do I resolve this?
TIA

Reply With Quote
  #8 (permalink)  
Old June 6th, 2006, 01:15 PM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,

Take a look here: http://www.adopenstatic.com/faq/80040e14.asp#scenario3a

The idea is that you replace a single quote with two quotes every time you try to update the database (either with an INSERT or an UPDATE statement). The database will know that '' actually means the literal value of ' and won't cause an error. However, only a single ' will be inserted in the database, so next time you need to get the data from the database, it'll look fine.

If you follow the link to the sample function, you see how you can create and use the Replace function to replace each single quote with a pair of quotes.

HtH,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Reply With Quote
  #9 (permalink)  
Old June 8th, 2006, 07:26 AM
Authorized User
 
Join Date: May 2006
Location: Bradford, , United Kingdom.
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still struggling...
Any chance of seeing an example with my code?

(an extract of my code)
mySQL = "INSERT into TABLE(BroDesc)"
mySQL = mySQL & " VALUES ('" & request.form("BroDesc") & "')"
myCon.execute(mySQL)

Hope to hear...



Reply With Quote
  #10 (permalink)  
Old June 8th, 2006, 07:32 AM
Imar's Avatar
Wrox Author
Points: 72,073, Level: 100
Points: 72,073, Level: 100 Points: 72,073, Level: 100 Points: 72,073, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Where is your Replace code??

Try something like this:

Dim myValue
myValue = Replace(request.form("BroDesc"), "'", "''")

Then use myValue instead request.form("BroDesc") in the rest of your code.


Imar


Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you translate an apostrophe? IronStar XSLT 2 November 13th, 2006 12:35 PM
cdonts and apostrophe bostonrose Classic ASP Components 3 October 23rd, 2006 08:20 AM
Javascript validation for apostrophe crmpicco Javascript How-To 2 March 2nd, 2005 06:57 AM
Apostrophe in textarea Renu ASP.NET 1.0 and 1.1 Basics 3 September 8th, 2004 02:13 PM
display vbCrLf's from textarea to textarea mat41 Classic ASP Basics 8 June 10th, 2004 12:19 AM



All times are GMT -4. The time now is 07:44 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.