Thanks Steve,
That's what I thought was causing the error, there was 0 returns. I've changed
the coding around now, so it's working like I wanted.
thx's again :)
>>On Sat, 22 Sep 2001 19:15:58 -0500, "Steve Howard" <[EMAIL PROTECTED]> wrote:
>>$active = $dbh->selectrow_array($sqlquery);
>>
>>and
>>$expire = $dbh->selectrow_array($sqlquery);
>>
>>
>>In that case, $expire will equal 0 when the count is 0 and the dbError
>>function is not called when 0 rows are returned.
>>
>>If you want the error returned when there really is an error, but not get an
>>error when 0 rows are returned, then handle the statements like this:
>>
>>$sth = $dbh->prepare($sqlquery) || die "Can't prepare $sqlquery\n
>>$DBI::errstr";
>>$sth->execute() || die "Can't execute $sqlquery\n $DBI::errstr";
>>$active = $sth->fetchrow_array();
>>
>># do something with $active now.
>>
>>Does this help?
>>
>>Steve H.
>>
>>-----Original Message-----
>>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
>>Sent: Saturday, September 22, 2001 6:38 PM
>>To: [EMAIL PROTECTED]
>>Subject: Avoid Error if no results
>>
>>
>>Hi All,
>>
>>this one seems to puzzle me on how to avoid an unnecessary db error. I need
>>to
>>run a tally count on a couple tables, and if there isn't any data in the
>>table
>>it displays the dbError, altho there isn't technical any syntax error in the
>>query other then no return or results.
>>
>>my $active = 0;
>>my $expire = 0;
>>
>>$sqlquery = qq|SELECT COUNT(m.memid) FROM members m,payhistory p
>> WHERE p.active = 'Y' AND p.memid = m.memid|;
>>$active = $dbh->selectrow_array($sqlquery) or dbError();
>>
>>$sqlquery = qq|SELECT COUNT(*) FROM expired WHERE expdate < CURDATE()|;
>>$expire = $dbh->selectrow_array($sqlquery) or dbError();
>>
>>Is this way to avoid the dbError() if the query returns no results(which
>>would
>>indicate a '0' tally.
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
http://www.thunder-rain.com
Tel: 1(225)686-2002
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=