]> git.mjollnir.org Git - moodle.git/commitdiff
Installer now checks that MySQL extension is present - see bug 1982
authormoodler <moodler>
Thu, 23 Sep 2004 05:40:53 +0000 (05:40 +0000)
committermoodler <moodler>
Thu, 23 Sep 2004 05:40:53 +0000 (05:40 +0000)
install.php
lang/en/install.php

index 9ab36e190a6c844fe5d51917433cdaded83afccd..9fea71ddbdd55a3871d185bb765c8fc5d4047e59 100644 (file)
@@ -213,24 +213,34 @@ if ($INSTALL['stage'] == 3) {
         }
     }
 
-    $db = &ADONewConnection($INSTALL['dbtype']);
+    if ($INSTALL['dbtype'] == 'mysql') {  /// Check MySQL extension is present
+        if (!extension_loaded('mysql')) {
+            $errormsg = get_string('mysqlextensionisnotpresentinphp', 'install');
+            $nextstage = 3;
+        }
+    }
 
-    error_reporting(0);  // Hide errors 
-    
-    if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
-        /// The following doesn't seem to work but we're working on it
-        /// If you come up with a solution for creating a database in MySQL 
-        /// feel free to put it in and let us know
-        if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) {
-            switch ($INSTALL['dbtype']) {   /// Try to create a database
-                case 'mysql':
-                    if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) {
-                        $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
-                    } else {
-                        $errormsg = get_string('dbcreationerror', 'install');
-                        $nextstage = 3;
-                    }
-                break;
+    if (empty($errormsg)) {
+
+        $db = &ADONewConnection($INSTALL['dbtype']);
+
+        error_reporting(0);  // Hide errors 
+
+        if (! $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname'])) {
+            /// The following doesn't seem to work but we're working on it
+            /// If you come up with a solution for creating a database in MySQL 
+            /// feel free to put it in and let us know
+            if ($dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'])) {
+                switch ($INSTALL['dbtype']) {   /// Try to create a database
+                    case 'mysql':
+                        if ($db->Execute("CREATE DATABASE {$INSTALL['dbname']};")) {
+                            $dbconnected = $db->Connect($INSTALL['dbhost'],$INSTALL['dbuser'],$INSTALL['dbpass'],$INSTALL['dbname']);
+                        } else {
+                            $errormsg = get_string('dbcreationerror', 'install');
+                            $nextstage = 3;
+                        }
+                        break;
+                }
             }
         }
     }
index ba5a815ec017acda14aa4375b59dc67f5ca7268c..cada2eb59c5c891a0ca46347bd5a857ae9cc10fc 100755 (executable)
@@ -110,6 +110,7 @@ $string['memorylimithelp'] = "
     <p>However, on some servers this will prevent <b>all</b> PHP pages from working \r
     (you will see errors when you look at pages) so you'll have to remove the .htaccess file.\r
 </ol>";\r
+$string['mysqlextensionisnotpresentinphp'] = 'PHP has not been properly configured with the MySQL extension so that it can communicate with MySQL.  Please check your php.ini file or recompile PHP.';\r
 $string['pass'] = 'Pass';\r
 $string['phpversion'] = 'PHP version';\r
 $string['phpversionerror'] = 'PHP version must be at least 4.1.0';\r