I'm trying to get past a few things that make me uncomfortable looking at this code.

First is the usual discomfort at seeing values interpolated directly into the SQL statement, rather than using placeholders.   Are you sure that $form{'item'} and $fdnum don't contain any spaces or apostrophes or something else that your SQL engine make think is something other than a value?   For that matter, do you need apostrophes surrounding those two variables?

Second is the strange use of 'handle' variable names.   I can see that $db is apparently your DBI database handle returned from connect().   Often people use $dbh for that handle value, and use something else for the statement handle.   Using $dbh instead of $sth for a statement handle causes a little queasiness for me.

Another thing that confuses me is that all the SQL statements are the same, at least as shown in your example.   What different behavior did you think you would get?

Enough blathering from me.   Why don't you back up and just check the results from your first prepare/execute/fetch set of statements.   Let's see, untested code ahead:

my ($mb_award,$mb_accept); $db->{RaiseError} = 1; # turn on error checking\ my $sth=$db->prepare( "SELECT mb_award,mb_accept FROM Items WHERE it +emnum=? AND seller=? AND closef='1'" ); $sth->execute($form{'item'},$fdnum); ($mb_award,$mb_accept) = $sth->fetchrow_array(); print " We see '$mb_award' and '$mb_accept'\n";

In reply to Re: DBI compare columns problem by shenme
in thread DBI compare columns problem by th3monk3y

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.