Hi,

I'm using perl to interact with MySQL. I hope someone can help me with the two questions below:

1) How do I obtain the time it takes for the query to complete? I see sites that use databases have something like "Results returned in 0.52 secs" at the bottom of the page. Is that a MySQL thing or is that from the application program (perl, php or java)?

2) I use the code below to check whether a username has been taken:

Code:
sub check_exist {
  # $username is passed from another subroutine
  my $username = shift; # line 1
  do_connect(); # line 2
  $sql = qq{ SELECT * FROM $table{'profiles'} WHERE  nick="$username"}; # line 3
  $sth = $dbh->prepare($sql); # line 4
  my $result = $sth->execute()
    or bail_out("Cannot execute query."); # line 5
  do_disconnect(); # line 6
  do_warn("$username has already been taken. Please choose another one...") if ($result ne '0E0'); # line 7
}
I'm concerned with line 7. If the username is not found in the database, the result returned is '0E0', so do_warn is called. Is that the right way to verify if a username has been taken?