[LON-CAPA-cvs] cvs: loncom /interface lonmysql.pm

matthew lon-capa-cvs@mail.lon-capa.org
Wed, 21 Aug 2002 21:29:51 -0000


matthew		Wed Aug 21 17:29:51 2002 EDT

  Modified files:              
    /loncom/interface	lonmysql.pm 
  Log:
  Deal cleanly with $dbh not being defined at all.  I have no idea how this
  happens, but appearantly it does.
  
  
Index: loncom/interface/lonmysql.pm
diff -u loncom/interface/lonmysql.pm:1.6 loncom/interface/lonmysql.pm:1.7
--- loncom/interface/lonmysql.pm:1.6	Mon Aug 12 10:50:18 2002
+++ loncom/interface/lonmysql.pm	Wed Aug 21 17:29:51 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # MySQL utility functions
 #
-# $Id: lonmysql.pm,v 1.6 2002/08/12 14:50:18 matthew Exp $
+# $Id: lonmysql.pm,v 1.7 2002/08/21 21:29:51 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -327,7 +327,10 @@
                                $Apache::lonnet::perlvar{'lonSqlAccess'},
                                { RaiseError=>0,PrintError=>0}))) {
         $debugstring = "Unable to connect to loncapa database.";    
-        if ($dbh->err) {
+        if (! defined($dbh)) {
+            $debugstring = "Unable to connect to loncapa database.";
+            $errorstring = "dbh was undefined.";
+        } elsif ($dbh->err) {
             $errorstring = "Connection error: ".$dbh->errstr;
         }
         return undef;