Gerald Clark wrote:
> in perl you would do
> my $qselcat=$dbh->quote($selcat);
> $whichpart = "AND key1=$qselcat";
>
> Ren� Fournier wrote:
>
> > Hello everyone,
> >
> > I'm trying to Select on a field that contains a doublequote, and can't
> > figure out how to pass it throught the Select statement (couldn't find
> > anything in the docs either...)
> >
> > -=-=-=-=-
> >
> > This doesn't work...
> >
> > $whichpart = "AND key1='$selcat'";
> > $result = mysql_query("SELECT * FROM parts WHERE status='online'
> > $whichpart",$db);
> >
> > ...when $selcat contains a double quote. For example, if I echo
> > $selcat, I get:
> >
> > AND key1='36\" Core Shafts'
> >
> > ======
> > I can see that mysql is choking on that double quote--do I need to
> > convert it to something else? Thanks.
> >
> > ...Rene
> >
> > ---
> > Ren� Fournier,
> > [EMAIL PROTECTED]
> >
> > Toll-free +1.888.886.2754
> > Tel +1.403.291.3601
> > Fax +1.403.250.5228
> > www.smartslitters.com
> >
> > SmartSlitters International
> > #33, 1339 - 40th Ave NE
> > Calgary AB T2E 8N6
> > Canada
> >
> >
> > ---------------------------------------------------------------------
> > 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
> >
> >
>
> ---------------------------------------------------------------------
> 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
FYI -
Be careful using dbh->quote with inserts and updates. If you feed dbh->quote a
variable that has
no value, it will return '' (tick tick). If the column is a date the value will
be set to 0000-00-00 and
if the column is numeric it will be set to 0 instead of NULL . You can either
check the length of the variable to see if you
can quote it, or use a sub_routine like below and call it instead of dbh->quote.
walt
#############################################################
# # nea_quote
# replacement for direct dbh->quote which doesn't work well with
# mysql which returns '' instead of NULL.
sub nea_quote
{
my ($input) = @_;
if (length($input) == 0)
{
$return_string = "NULL";
return $return_string;
}
else
{
$return_string = $dbh->quote($input);
return $return_string;
}
}
---------------------------------------------------------------------
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 <mysql-unsubscribe-##L=##[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php