Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Weird Record Number (-2)

Quote Reply
Weird Record Number (-2)
Okay...I've rewritten my "total users online" subroutine since I noticed that it was not taking the DISTINCT number of rows from the Sessions table. The problem is that now the number has a - character attached to it.

You can see what I mean at:

http://members.anthrotech.com

Here is the query I am using:

Code:

sub get_totalonline {
#-----------------------------------------------------
my ($USERSESSDB);
$USERSESSDB = new Links::DBSQL $CUSTOM{members_def} . "Sessions.def";
my $query = qq|SELECT DISTINCT(UserID) FROM Sesssions|;
my $sth = $USERSESSDB->prepare($query);
$sth->execute();
my $hits = $sth->rows;
return $hits;
}


Of course, if my hosting company upgraded to the next version of MySQL where my anthrotech databases are stored, I could use COUNT(DISTINCT(UserID)) in the above SQL statement. But since they aren't planning on upgrading this particular MySQL server, I am stuck with using legacy MySQL functions/codes. [sad]

Anyway...does anyone see something I am missing with the above query that is inserting negative signs before the number???

Thanks in advance for any suggestions!

Regards,

Eliot Lee Wink
http://anthrotech.com/
Quote Reply
Re: Weird Record Number (-2) In reply to
Hi,

-2 means there was an error in the query. Try returning $DBI::errstr.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Weird Record Number (-2) In reply to
Thanks, Alex...I have to remember to turn on debugging or use the error call you posted. I'll look into this.

Regards,

Eliot Lee Wink
http://anthrotech.com/