in reply to MySQL does not like me today...

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.