Results 1 to 5 of 5

Thread: MySQL Post Textarea Problem

  1. #1
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default MySQL Post Textarea Problem

    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!!!!

  2. #2
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Are you using php?
    if so try adding this to the page:
    Code:
    <?
    $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
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. #3
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No, I'm actually using java. Do you have anything to escape the quotes using java?

    Thanks.

  4. #4
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Im am not really a java person, but try this:
    Code:
    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")); 
    } 
    }
    untested.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #5
    Join Date
    Apr 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks. I will try this out when I get back to work. Thanks again.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •