Try to use place holder, it probably will help, at least remove one possible gotcha.

SELECT * FROM users WHERE name = ? AND pass = ?

Use the following syntax:

@row_ary = $dbh->selectrow_array("SELECT * FROM users WHERE name = ? A +ND pass = ?", undef, @binding_values);

Use $dbh->err() to tell you the exact database error.

if you want to see whether there is a row satify certain condition, just say,

SELECT 1 FROM users WHERE name = ? AND pass = ? #replace * with 1

In your case, there is really no need to run the same query twice:

if($dbh->selectrow_array("SELECT * FROM users WHERE name = $uname_q +AND pass = $pword_q")){ ($userid) = $dbh->selectrow_array("SELECT userid FROM users WH +ERE name = $uname_q AND pass=$pword_q");

You said that after you comment out the first if and the else block, it complains about $userid. That is a good indication that your query probably failed, according to the document, an empty list will be retunred in that case.


In reply to Re: MySQL does not like me today... by pg
in thread MySQL does not like me today... by Spidy

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.