Since you're sending this to the Perl list I will assume you're using
DBI::mysql to interface with MySQL.

Use the DBI method "quote()",
as in:
    # assuming:
    # my $dbh = DBI->connect(...) has gone before
    $dbh->quote($Value);

Here's a little sub routine I picked up from CodeCharge a while back; I use
it for quick RAD development:

#-------------------------------
# Convert value for use with SQL statement
#-------------------------------
sub ToSQL {
  my ( $Value, $sType ) = @_;
  if ( $Value eq "") {
    if ($sType eq "notnull") {
      return $dbh->quote(" ")
    } else {
      return "Null"
    }
  } else {
    if ( $sType eq "Number" ) {
      return 0+replace($Value, ",", ".");
    } else {
      return $dbh->quote($Value);
    }
  }
}

#-------------------------------


----- Original Message ----- 
From: "Pablo Fischer" <[EMAIL PROTECTED]>
To: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Saturday, September 20, 2003 2:34 PM
Subject: Single and Double quotes in SQL


> Hi!
>
> I need to save some HTML text in a DataBase (MySql, using DBI). However
> some HTML text will have single and double quotes, so.. how can I save
> them?, for example:
>
> <align="center">It's so funny</align>
>
> Thanks!
> Pablo
> -- 
> Pablo Fischer Sandoval (pablo -arroba- pablo.com.mx)
> http://www.pablo.com.mx
> http://www.debianmexico.org
> GPG FingerTip: 3D49 4CB8 8951 F2CA 8131 AF7C D1B9 1FB9 6B11 810C
> Firma URL: http://www.pablo.com.mx/firmagpg.txt
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to