LPM: Many Monkeys: Question about quotes

Joe Hourcle oneiros at dcr.net
Thu Jan 13 14:30:37 CST 2000



On Thu, 13 Jan 2000, Mik Firestone wrote:

> 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.


>From my vague recollection of the August meeting, when this was mentioned,
(please, correct me if I'm wrong), this also places the corresponding
quotes around the string, not just escaping the approprate strings, so
you'd want to do something along the lines of :

	my $headline = $dbh->quote('The American Experience on KET looks at the life of Harry Houdini');
	my $id = $dbh->quote('2000/02/AmExp.Houdini');
	my $string = "update release set headline=$headline where id=$id;";

[I'm guessing that the original problem was that the database in question
was expecting '' as the string qualifier, but the above should be more
portable]

> > 	$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 

-----
Joe Hourcle




More information about the Lexington-pm mailing list