Perhaps I misunderstand your code, but you already have the values for mb_award and mb_accept after your initial SELECT. Why do you fetch them again with two more SQL commands?

Your SELECT statements are also insecure if the $form{item} or $fdnum variables are under the control of a user; you should either use ? placeholders or else quote them.

Also, try using the -w switch and use strict, and see if that points you to any errors. And, you don't do any error checking from your various DB calls, so no matter how badly DBI wants to tell you where your error is, it can't.

It's weird to use a string for numeric comparisons. You probably just want if ($mb_award > 0) {.

It's a little weird to assign the array returned from $dbh->fetchrow_array() to a single value. I think it will work, but if the array actually returns more than one thing it may not do what you expect. It would be more idiomatic to say:

($mb_amount_disp) = $dbh->fetchrow_array();

If none of these hints help, you'll need to post some sample rows, what you expect to happen, and what actually happens. The code here certainly does something, but it may not be the same thing you want it to do...


In reply to Re: DBI compare columns problem by sgifford
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.