Actually, you disconnect your database handle...in this case:
$dbh->disconnect;
but that's not what I see in your script.
What I see happening in your script is that you are connecting twice using
the same database handle without ever disconnecting the database handle the
first time. There should be no reason to connect to the same database a
second time in this script unless you are using the results from the
statement handle in the first database handle in the query in the second
database handle. In this case, you aren't, so take out the second connection
string, and you should get rid of this error. The disconnect error should
not occur even if you do not explicitly disconnect from the database before
the end of the script - unless you have uncommitted transactions (unlikely
if you are using MySQL).
If you ever need to use the results of the first query in a second query
before finishing with the first statement handle, simply use a different
database handle, and statement handle for the second one: ex: $dbh1, and
$sth2. or $Mysql_Database and $insert...or whatever makes sense to you to
use....$dbh, and $sth are only examples of database and statement handles.
You can use whatever makes sense in your program.
Hope this helps.
Steve Howard
-----Original Message-----
From: Brent Michalski [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 11, 2001 9:02 AM
To: FLAHERTY, JIM-CONT
Cc: Beginners (E-mail)
Subject: Re: Issuing rollback() for database handle being DESTROY'd
without explicit disconnect().
I saw no $dbi->disconnect; statement in your code. If you do not
disconnect, and the program ends, you will get the above message....
brent
"FLAHERTY,
JIM-CONT" To: "Beginners (E-mail)"
<[EMAIL PROTECTED]>
<Jim.Flaherty@cnet cc:
.navy.mil> Subject: Issuing
rollback() for database
handle being DESTROY'd without
ex plicit
06/11/01 09:00 AM disconnect().
Why am I getting this ??
Issuing rollback() for database handle being DESTROY'd without explicit
disconnect().
the code
#!/usr/bin/perl
####################################
# Script to maintain KBHD Stats #
# Version 1.0 #
# date : 6 Jun 01 #
####################################
# require "subparseform.lib";
# &Parse_Form;
###############################
# Start Writing the Page #
###############################
open(LOG,">/var/www/html/kbhd/stats.php");
print LOG "<HTML><HEAD>\n";
print LOG "<Title> Stats for Techs </title>\n";
print LOG "</head>\n";
print LOG "<body bgcolor=\"#C0C0C0\" text=\"FFFF00\">\n";
print LOG "<div align=\"center\">\n";
print LOG " <h1>Stats Page</h1>\n";
print LOG " </div>\n";
print LOG "<hr align=\"center\" size=\"4\" width=\"80%\">\n";
# <!-- this is the Stats Page , it will have reports total jobs and grades
-->
######################################################
# get stats
######################################################
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "user";
my $password = "password";
$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select count(*)from jobs where status =
'closed'");
$sth1 -> execute or die " unable to execute query ";
my $array_ref = $sth1 -> fetchall_arrayref();
foreach $row(@$array_ref){
my($closedJ) = @$row;
}
print LOG "<p> ";
print LOG " <font color=\"#800080\"><b>Overall Stats</b></font></p>";
print LOG "<div align=\"center\">\n";
print LOG " <center>\n";
print LOG " <table border=\"1\" width=\"80%\">\n";
print LOG " <tr>\n";
print LOG "<td width=\"38%\" bgcolor=\"#FFFFFF\"><b>";
print LOG "<font color=\"#0000FF\">Number Of ";
print LOG "Closed Jobs : ";
print LOG "</font><font color=\"#000000\">\n";
print LOG "$closedJ </font></b></td>\n";
print LOG "<td width=\"30%\">Total Time</td>\n";
print LOG "<td width=\"34%\">Average time per Call</td>\n";
print LOG " </tr> \n";
print LOG "</table>\n";
print LOG "<br><hr size=\"4\">\n";
print LOG "<b>Grades for techs </b>\n";
###############################################
# Query techs names #
###############################################
use DBI;
my $database = "VHD";
my $data_source = "DBI:mysql:$database";
my $username = "";
my $password = "";
$dbh =DBI ->connect($data_source, $username, $password);
my $sth1 = $dbh -> prepare("select username from tech1");
$sth1 -> execute or die " unable to execute query ";
my $array_ref = $sth1 -> fetchall_arrayref();
foreach $row(@$array_ref){
my($tech) =@$row <mailto:=@$row> ;
print LOG "<center> $tech </center><br>\n";
print LOG " <table border=\"1\" width=\"40%\" bgcolor=\"#00FF00\">\n";
print LOG "<TR>\n";
print LOG " <td width=\"57%\"><b> Total Jobs
Completed</b></td>\n";
print LOG " <td width=\"6%\"> </td>\n ";
print LOG "<td width=\"37%\"> <b><font color=\"#0000FF\">
53</font><
/b></td>\n";
print LOG " </tr>\n";
print LOG " <tr> \n";
print LOG "<td width=\"57%\"> <b> Total Hours Spent
</b><
/td>\n";
print LOG "<td width=\"6%\"> </td>\n";
print LOG "<td width=\"37%\"> <font
color=\"#0000FF\"><b>56</b
></font></td>\n";
print LOG " </tr>\n";
print LOG " <tr>\n";
print LOG "<td width=\"57%\"> </td>\n";
print LOG " <td width=\"6%\"> </td>\n";
print LOG " <td width=\"37%\"> </td>\n";
print LOG " </tr>\n";
print LOG " <tr>\n";
print LOG "<td width=\"57%\"> <font color=\"
#000000\"><b>Average
time to";
print LOG "Complete</b></font> </td>\n";
print LOG " <td width=\"6%\"> </td>\n";
print LOG "<td width=\"37%\"> <font
color=\"#0000FF\"><b>67</b
></font></td>\n";
print LOG " </tr>\n";
print LOG " </table>\n";
print LOG "<br><br>\n";
}
close(LOG);