 |
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 5th, 2006, 01:59 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Apostrophe in a textarea
Hi,
How do I get round the problem of an (') apostrophe in a textarea?
Thanks.
|
|

June 5th, 2006, 02:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Can you be more specific, what is the problem and do you have an example?
Cheers,
Chris
|
|

June 5th, 2006, 03:57 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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'.
|
|

June 5th, 2006, 04:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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?
|
|

June 5th, 2006, 04:06 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Error Type:
Microsoft JET Database Engine (0x80040E14)
Syntax error (missing operator) in query expression ''I'm testing')'.
/TheMiddlePath/matconfirm.asp, line 41
|
|

June 6th, 2006, 02:51 AM
|
|
Friend of Wrox
|
|
Join Date: Jul 2003
Posts: 683
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

June 6th, 2006, 01:06 PM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

June 6th, 2006, 01:15 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 8th, 2006, 07:26 AM
|
|
Authorized User
|
|
Join Date: May 2006
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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...
|
|

June 8th, 2006, 07:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|
 |