[Israel.pm] Database Insertion

Uri Bruck bruck at actcom.net.il
Fri Jun 17 06:53:23 PDT 2005


Georges EL OJAIMI wrote:
> Hello,
> 
> I am trying to insert random text into a MySQL field. I am having problem in (data = '$datafile') if the original data contain single quote ('). How can I automatically add a trailing slash if found before each single quote in the data?
I use the DBI module for mysql. It has a quote class method that takes 
escapes all the characters that need to be escaped.
Suppose your database handle is $dbh, then instead of
"data = '$datafile'"
use:
" data = ".$dbh->quote($datafile)

> 
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl


-- 
Thanks,
Uri
http://translation.israel.net



More information about the Perl mailing list