This question comes up very frequently - I posted code sometime back
that is a sure fire fix to that problem -


public String apQuote(String s ) {
StringBuffer result = new StringBuffer();

for (int i=0;i<s.length();i++) {
char c = s.charAt(i);
if (c!=39){ result.append(c);
 }else{
 result.append(c);
} //end if
 }
es =  result.toString( );
return es;
}


----- Original Message -----
From: Randy Troppmann <[EMAIL PROTECTED]>
Date: Wednesday, April 4, 2001 2:22 pm
Subject: how to escape apostrophe

> Hello all,
>
> When I accept input from an HTML form, apostraphes(single quotes)
> screw up
> my SQL query syntax. I tried to write a method that searched the
> string and
> put an escape character in front, but this wouldn't work for me. I
> endedsubstituting the ' character with I think is an accent grave `.
>
> Does anyone have a better idea?
>
> Thanks!
> Randy Troppmann
>
>
________________________________________________________________________
___
> To unsubscribe, send email to [EMAIL PROTECTED] and include in
> the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http:
> Resources: http://java.sun.com/products/servlet/external-
> resources.htmlLISTSERV Help:
> http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to