Hi,
Escaping the apostrophe might not be the best solution. Other characters
could cause troubles. PreparedStatement is the answer to such problem.
Pierre-Yves
-----Message d'origine-----
De : A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]De la part de
Barbara Johnson
Envoy� : jeudi 20 septembre 2001 20:54
� : [EMAIL PROTECTED]
Objet : replacing apostrophes
Hello All,
I need to replace apostrophes from in the text a user puts in a form input
textboxe before the text goes into the mysql database. If apostrophes go
into the database it gets corrupted.
I tried the "replace" function and can use it to replace a letter but am
having trouble with the syntax to use
to tell it to replace an apostrophe because the function says to use single
quotes around the variables that you are replacing.
This works:
String str = "aaabbbccc";
out.println (str.replace('a','b'));
This doesn't work:
String str = "aaabbbccc";
out.println (str.replace(''',''''));
I tried subsituting the outer single quotes with double quotes. That doesn't
work either.
Any suggestions would be appreciated.
Thanks,
Barbara Johnson
Instructional Applications Programmer
[EMAIL PROTECTED]
Northeastern Ohio Universities College of Medicine
___________________________________________________________________________
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
___________________________________________________________________________
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