Forums

This topic is locked

stripping single quotes

Posted 01 Jan 2003 17:26:23
1
has voted
01 Jan 2003 17:26:23 Dave Clarke posted:
hi

i'm using this code to strip single quotes from a users form input

<b>strAddmessage = Replace(Request("addmessage", "'", "''"</b>

this works fine until it comes across form inputs that contain double quotes then it strips out everything from the double quote onwards and inserts that into the db

e.g form input

<b>my name is "dave" and i am 36</b>

would insert into db as

<b>my name is</b>

any ideas??

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Replies

Replied 03 Jan 2003 01:06:18
03 Jan 2003 01:06:18 Dave Clarke replied:
I think the problem above is actually the DW insert behaviour rather than the replace, because even without the replace nothing after a " is inserted into the database.

So this now leads to the question how can I use replace to replace double quotes with 2 single quotes, because if I use this code

<b>strString = Replace(Request.Form("formfield", """, "''"</b> it doesn't work as the three double quotes are not interpreted correctly.

I hope that makes sense.

Thanks

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome
Replied 03 Jan 2003 01:19:37
03 Jan 2003 01:19:37 Dave Clarke replied:
Hi

Done it!

changed the 3 double quotes to 4 double quotes and hey presto any double quotes entered in the form field are replaced with 2 single quotes.

Now I have to find something to replace single quotes with that looks better than 2 single quotes because don''t doesn't look as good as don't does it? <img src=../images/dmxzone/forum/icon_smile_big.gif border=0 align=middle>

Dave

ASP|VBScript|IIS5.1|Access|WinXPPro & WinXPHome

Reply to this topic