this seems simple, but i'm running into confusion: i have the following very simple SQL statement:
my $sql = "SELECT UID FROM news";
and then the following loop to match the requested UID with the results of the query, and identify the previous and next records:
while (my $newUID = $sth->fetchrow) { if ($in{'requestID'} == $newUID) { $currID = $newUID; } else { $prevID = $newUID; } ... #there's a counter to generate one more loop after the currID is f +ound, to capture "nextID" $nextID = $newUID; } print p(["Previous = |$prevID|","Current = |$currID|","Next = |$nextID +|"]);
so, if i submit the value 2 as 'requestID', the results for $prevID is correctly listed as 1, $currID is undefined, and $nextID gets assigned as 2. this is what it looks like:
0 #this is a counter value to escape the while loop after finding the +value of $nextID Previous = |1| Current = || Next = || 1 Previous = |1| Current = || Next = |2|

it seems to me that the condition ($in{'requestID'} == $newUID) is not getting evaluated correctly, and i'm wondering if one of the other value is not recognized as an integer? is that the problem? how do i fix it? the database file is MySQL, and the UID field is defined as an integer field.

TIA, janaki

In reply to datatype from SQL by jck

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.