View Full Version : MySQL Post Textarea Problem

04-10-2008, 07:36 PM
I'm new to application development. I have a web based form that contains a text area. When someone types there information into the textarea it is posted to the MySQL database with no problem. However, if someone copy and paste text that contains single or double quotes into the textarea I get errors. Please help!!!!

04-10-2008, 08:10 PM
Are you using php?
if so try adding this to the page:

$submitted_string = addslashes($submitted_string);
//with $submitted_string being the sting that contains the message.

that should escape the quotes.
If you have a problem, please ask :)

04-10-2008, 08:15 PM
No, I'm actually using java. Do you have anything to escape the quotes using java?


04-10-2008, 08:27 PM
Im am not really a java person, but try this:

import java.util.*;
public class quote{
public String addSlashes(String str){
if(str==null) return "";
StringBuffer s = new StringBuffer ((String) str);
for (int i = 0; i < s.length(); i++)
if (s.charAt (i) == '\'')
s.insert (i++, '\\');
return s.toString();
public static void main(String args[]) {
quote qt=new quote();
System.out.println(qt.addSlashes("the message's varable here"));


04-10-2008, 09:03 PM
Thanks. I will try this out when I get back to work. Thanks again.