Maybe I'm misreading what you did, but $dbh->quote($group) adds the single
quotes around the string, so using it followed by "...WHERE
newsgroup='$group'"  gets you

WHERE newsgroup=''name.of.group''

Also, your example sets $newsgroup using quote, but uses $group in the
query, which is a problem, of course, if you really did that.

Try this:

$newsgroup = $dbh->quote($group);
$sth = $dbh -> prepare ("SELECT expiration from newsgroups
                         WHERE newsgroup=$newsgroup");
$sth -> execute;

Michael

On Fri, 10 May 2002, 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;
>
> $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);
>
> $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

Reply via email to