LPM: Many Monkeys: Question about quotes
Mik Firestone
fireston at lexmark.com
Thu Jan 13 14:10:42 CST 2000
If I have understood the issue correctly, you should be able to use the:
$dbh->quote($string)
to "correctly" backslash the string. Correctly here is defined as correct
with respect to your database - different databases need different characters
protected and this function is supposed to handle that.
Mik
PS - Erik Ackerman says Hi!
On Thu, 13 Jan 2000, David Hempy wrote:
>
> I've got quotes coming out of my ears! I am constructing a SQL statement
> as such:
>
> $cmd = qq {update release set headline="$headline" where id="$id" };
>
> This works fine and dandy, quoting the headline and id as such:
>
> update release set headline="The American Experience on KET looks at the
> life of Harry Houdini" where id="2000/02/AmExp.Houdini"
>
> Only problem is, I got a headline of:
>
> Mike Holloway "The South paw from Arkansas" - on next Jubilee on KET
>
> Thus, the word [The] appears as a bare word in my SQL statement, generating
> a SQL error. I expect there will be headlines with both double quotes and
> single quotes.
>
> Since this field is primarily destined to be html code, I wimped out by
> changing $headline first:
>
> $headline =~ s/\"/"/g; ## Escape quotes within the title.
>
> I'll need to un-do this later if I have any non-html outlets, but that's
> not a problem for this project. I would still like to find an answer to
> this for the future. I tried \ escaping the quotes in the headline, but
> the backslashes made it into the database, which is not what I want. I'm
> thinking this is more of a SQL question than a perl question at this point.
>
> Don't sweat it, but if anyone has any insight, I'd be happy to learn.
>
> -dave
>
>
>
>
> --
> David Hempy
> Internet Database Administrator
> Kentucky Educational Television
>
>
--
Mik Firestone fireston at lexmark.com
When I become an Evil Overlord:
My troops will receive special training so that they may shoot the tires of a
moving vehicle.
More information about the Lexington-pm
mailing list