]> git.mjollnir.org Git - moodle.git/commitdiff
If the database doesn't work then just die before anything else
authormoodler <moodler>
Sat, 7 Dec 2002 07:27:58 +0000 (07:27 +0000)
committermoodler <moodler>
Sat, 7 Dec 2002 07:27:58 +0000 (07:27 +0000)
lib/setup.php

index dfa2af0ef1a8554d83c360380bb560990a318091..488ee0fc460289e5b99b6364d4b045d7e0937f28 100644 (file)
 /// If there are any errors in the standard libraries we want to know!
     error_reporting(15);   // use 0=none 7=normal 15=all 
 
+/// Connect to the database using adodb
+
+    require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
+    ADOLoadCode($CFG->dbtype);          
+    $db = &ADONewConnection();         
+    if (! $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname)) {
+        echo "<P><FONT COLOR=RED>The database details specified in config.php are not correct, or the database is down.</P>";
+        die;
+    }
+
+
 /// Load up standard libraries 
 
     require("$CFG->libdir/weblib.php");          // Standard web page functions
-    require("$CFG->libdir/adodb/adodb.inc.php"); // Database access functions
-    require("$CFG->libdir/adodb/tohtml.inc.php");// Database display functions
     require("$CFG->libdir/moodlelib.php");       // Various Moodle functions
 
-/// Connect to the database using adodb
-
-    ADOLoadCode($CFG->dbtype);          
-    $db = &ADONewConnection();         
-    $db->PConnect($CFG->dbhost,$CFG->dbuser,$CFG->dbpass,$CFG->dbname); 
 
 /// Set error reporting back to normal
     error_reporting(7);