Groups | Blog | Home
all groups > inetserver asp general > august 2006 >

inetserver asp general : Issues with ' and %27


Jay
8/31/2006 11:40:04 AM
First, the ' should be converted to the HTML character code which i think
is:
'

ASP thinks that a double quote also is end of statement....try this:

dim StaffHowtToSpendTimeWork
StaffHowToSpendTimeWork = Request.Form("StaffHowToSpendTimeWork")
StaffHowtToSpendTimeWork = replace(StaffHowToSpendTimeWork,"'","'")



do the same think for double quotes. If you are going to use a double quote,
they have to be in doubles themselves

"
will throw an error


""
will not throw an error

the HTML character code for a double quote is

"


hope this helps



[quoted text, click to view]

Drew
8/31/2006 12:30:04 PM
I am having difficulty fixing a problem with one of my apps. I know that
using an apostrophe will error the SQL statement out, since it thinks that
the apostrophe is the end of the statement. My issue is that I have replace
code in my app that is *supposed* to replace the apostrophe with double
quotes. This has been working fine, no complaints until a user tried to
insert the word, does'nt (I know, it is spelled incorrectly, but ASP
shouldn't care). The form data shows the line to be,

StaffHowToSpendTimeWork=Name+does%27nt+like...

Now my replace code looks like this,

dim StaffHowtToSpendTimeWork
StaffHowToSpendTimeWork = Request.Form("StaffHowToSpendTimeWork")
StaffHowtToSpendTimeWork = replace(StaffHowToSpendTimeWork,"'","''")

Is there a difference between ' and %27? How can I fix this?

Thanks,
Drew

Bob Barrows [MVP]
8/31/2006 1:25:54 PM
[quoted text, click to view]

That only happens if you are using dynamic sql. See here for a better
way:
http://groups-beta.google.com/group/microsoft.public.inetserver.asp.db/msg/72e36562fee7804e

[quoted text, click to view]

Do you mean two apostrophes? That's the correct way to escape single
quotes in sql statements, not double quotes

[quoted text, click to view]

Huh? The user typed in "%27"?

[quoted text, click to view]
Stop doing this replacement. Use parameters.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Evertjan.
8/31/2006 5:13:24 PM
Drew wrote on 31 aug 2006 in microsoft.public.inetserver.asp.general:

[quoted text, click to view]

Replace the apostroph with a single back quote [accent grave].

O'Brien -> O`Brien

[In screen output, you can (re)place the apostrophe back,
but it doesn`t bother me in Dutch]

--
Evertjan.
The Netherlands.
AddThis Social Bookmark Button