Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Fellow monks, I have an odd database problem. I'm implementing user registration on my website; in my user validation, I have code like this:
$SQL = "SELECT COUNT(*) FROM Members WHERE Nickname = '?'"; $Statement = $Database->prepare($SQL); $Statement->execute($NickName); my @numrows = $Statement->fetchrow_array; rint "NumRows: @numrows"; if (($Statement->rows) > 0) { LogError("NICK_TAKEN"); return("-1"); }
The problem is this: I can never get the $Statement to return anything when selecting a Nickname I know exists. If I try this in the mysql monitor (using the same user login and machine as this script runs on, and the exact same query), I get back one row; but inside this script, nothing. I've also tried my $NumRows = $Statement->rows but that always returns zero rows. I'm using CGI.PM with fatalstobrowser. I tried modifying the username, and it expectedly spits out a database login error with the modified username - but with the "correct" username, I get nothing. I've done things like this before without a problem. Where can I look that would give me an indication of what is breaking down?

UPDATE: Thanks for the hints, everyone. I should have clarified earlier that I actually tried to select the rows and then count them, then I read the CPAN warning and decided to use SELECT COUNT(*) instead. In the end, removing the single quotes worked.

In reply to Odd Database Behavior by SpritusMaximus

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (12)
    As of 2021-04-12 21:28 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found