At 17:49 +0200 5/10/02, Mark wrote: > > This is too weird; I can quote until I see blew in the face, but I cannot >> seem to make MySQL understand that the name 'group-name' is valid to >> select. It keeps blabbing "You have an error in your SQL syntax". I mean, >> what is the purpose of its own quote function if it can not even quote >> properly? Every other name works fine, except when a WHERE clause looks >> for a column whose value has a dash in it. [/snip] >> >> Can we see the query? >> >> Jay > >Sure. > >$sth = $dbh -> prepare ("SELECT expiration from newsgroups WHERE >newsgroup='$group'"); >$sth -> execute;
$sth = $dbh->prepare ("SELECT expiration FROM newsgroups WHERE newsgroup = ?"); $sth->execute ($group); Note: no quotes around the placeholder character. > >$group is a newsgroup name; all queries go fine, except one that has a dash >in it. I have tried quoting $group, like: > >$newsgroup = $dbh -> quote ($group); That will work, unless you left the quotes around the variable in the statement. > >$group, btw, where it goes wrong, is a recovery newsgroup called >"alt.support.abuse-partners". > >I have had Perl quotemeta the whole thing, I haver dropped and added the >single-quotes, I have used place-holders, etc. But I always get, "You have >an error in your SQL syntax". > >Funnily enough, I had no problem inserting the name into the column. > >Sigh. This is such a newbie question, I realize it. But it is rather >frustrating. I appreciate your help. > >- Mark > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php