On Sun, 18 Mar 2001 19:22:20 -0700, Keary Suska wrote:
>The error indicates that the content you are interpolating contains
>unescaped single quotes, which confuses the parser, since you are using
>single quotes as the string delimiters. It's like doing:
> print "This text is "quoted" when printed\n";
>
>Call $dbhandle->quote() on each string to correct this.
Or use placeholders. That's one thing that they're for.
The original code:
>>$dbhandle->do( "INSERT INTO $table
>> (name, dwarf_list, occupations)
>> VALUES(\'$name\', \'$dwarves_str\', \'$occupations_str\')" );
Then can become:
$dbhandle->do("INSERT INTO $table (name, dwarf_list, occupations)
VALUES(?,?,?)", undef,
$name, $dwarves_str, $occupations_str);
Or, especially if you need to do several of them in a row:
my $sth = $dbhandle->prepare( "INSERT INTO $table
(name, dwarf_list,occupations)VALUES(?,?,?)");
$sth->execute($name, $dwarves_str, $occupations_str);
with no need to repeat the former statement in order to do several of
the latter.
Untested, of course. ;-)
--
Bart.