on do, 17 okt 2002 08:01:07 GMT, Andrew Hubbard wrote:

>      I'm having problems with a text file I'm working on. I need to
>      get 
> the descriptions in from the text file and into a 
> string for use in an SQL statement however some of the descriptions
> use a single quote mark in the description. 
> This of course stops the sql statement from working.
> 
> How can I get around this? I don't want to remove the quote. 

Use placeholders, like so:

    my $sth = $dbh->prepare("INSERT INTO atable VALUES(?,?)");
    my $value1 = "Looks like 'single' quotes";
    my $value2 = "No single quotes here";
    $sth->execute($value1, $value2);

    my $rset = $dbh->selectall_arrayref( qq{
        SELECT
            atable.afield,
            atable.anotherfield
        FROM atable
        WHERE
            atable.anotherfield = ?
    }, undef, $avalue);


-- 
felix

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

Reply via email to