On 18 May 2004 19:12:19 -0000
[EMAIL PROTECTED] (PerlDiscuss - Perl Newsgroups and mailing lists) wrote:

> I cant find a simple perl function to replace characters in a string. Im
> trying to inserts strings like "bob's" into a database and need to convert
> that to "bob''s" so that sql doesnt whine when i do an insert.
> 
> Any suggestions?

hi

try to use DBI module
see perldoc DBI and quote method


quote

  $sql = $dbh->quote($value);
  $sql = $dbh->quote($value, $data_type);

    Quote a string literal for use as a literal value in an SQL statement, by escaping 
any special characters (such as quotation marks) contained within the string and 
adding the required type of outer quotation marks.

  $sql = sprintf "SELECT foo FROM bar WHERE baz = %s",
                $dbh->quote("Don't");

    For most database types, quote would return 'Don''t' (including the outer 
quotation marks).



> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 


-- 
Frédéric Sapet

***********************
Génoplante-Info
523 place des Terrasses
91000 Evry
01 60 87 37 59
[EMAIL PROTECTED]
***********************

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to