List:MySQL on Win32« Previous MessageNext Message »
From:Cadbury Date:July 30 2004 2:47am
Subject:Ignoring or filtering ' char
View as plain text  
hi

i'm using Java to write a program that access mysql
database. here's a part of the java program source
code:

---------------------------------------------------------
query = "insert into userinfo values ('" +
emailSubject + "');";
executeUpdate(query);
---------------------------------------------------------

basically what the program does is it will insert an
incoming email's subject into a mysql table.

the problem occurs when the subject has the character
' in it. For example if the subject is something like
:"You've got a mail",mysql will give an exception
which looks something like this:

------------------------------------------------------
java.sql.SQLException: Syntax error or access
violation,  message from server: "
You have an error in your SQL syntax.  Check the
manual that corresponds to your MySQL server version
for the right syntax to use near 've got

','Fri Jul 30 10:11:04 GMT+08:00 2004')' at line 1"
------------------------------------------------------
from what I can see MySql treats the ' char as part of
mysql syntax. how can i overcome this problem? any
help are greatly appreciated.

Thanx.





	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 
Thread
Using a Blob with the ByteFX data providerNick Randell16 Jul
  • RE: Using a Blob with the ByteFX data providerReggie Burnett19 Jul
    • RE: Using a Blob with the ByteFX data providerNick Randell20 Jul
      • Suggested settings for dual processor machine?East Bay Technologies20 Jul
      • RE: Using a Blob with the ByteFX data providerReggie Burnett20 Jul
      • Should I use myISAM or InnoDB??East Bay Technologies21 Jul
      • Should I use myISAM or InnoDB??East Bay Technologies23 Jul
      • Suggested settings for dual processor machine?East Bay Technologies23 Jul
RE: Should I use myISAM or InnoDB??PF: MySQL23 Jul
  • Question about Insert StatementDanny Willis23 Jul
    • Re: Question about Insert StatementTata Respecia24 Jul
      • Ignoring or filtering ' charCadbury30 Jul
        • Strange site error.Danny Willis30 Jul
        • Re: Ignoring or filtering ' charTiago Serafim30 Jul
          • Re: Ignoring or filtering ' charCadbury4 Aug
            • Re: Ignoring or filtering ' charTiago Serafim4 Aug
              • Re: Ignoring or filtering ' charCadbury5 Aug
        • Re: Ignoring or filtering ' charPetr Vileta30 Jul
          • Re: Ignoring or filtering ' charTiago Serafim30 Jul
Re: Question about Insert StatementRandy Clamons24 Jul