LPM: Many Monkeys: Question about quotes

David Hempy hempy at ket.org
Thu Jan 13 13:57:59 CST 2000


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




More information about the Lexington-pm mailing list