Question : Apostrophe Problem

I am coming up with a problem when I submit text with an apostrophe in the text from a textbox to mysql using perl.

Error mesage I get is:
DBD::mysql::st execute failed: 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 't

When for example i use the word "doesn't" in the text.

I know I should be using escaped characters but I can't seem to get the apostrophe part working.  

For newline I use the following command:
$text =~ s/\n/
/g;

Can you please help.

Answer : Apostrophe Problem

MySQL requires single quotes to be deleimited by another quote such as:  d o e s ' ' t.

If you use placeholder, DBI will handle all the quoting for you
$sth = $dbh->prepare("INSERT INTO table(foo,bar) VALUES (?,?");
$sth->execute( $foo, $bar);  # $bar  can contain single quotes
Random Solutions  
 
programming4us programming4us