From: moodler Date: Thu, 23 Sep 2004 05:40:53 +0000 (+0000) Subject: Installer now checks that MySQL extension is present - see bug 1982 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=fe51520688a962c1834c2e835985a0361a72581b;p=moodle.git Installer now checks that MySQL extension is present - see bug 1982 --- diff --git a/install.php b/install.php index 9ab36e190a..9fea71ddbd 100644 --- a/install.php +++ b/install.php @@ -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; + } } } } diff --git a/lang/en/install.php b/lang/en/install.php index ba5a815ec0..cada2eb59c 100755 --- a/lang/en/install.php +++ b/lang/en/install.php @@ -110,6 +110,7 @@ $string['memorylimithelp'] = "

However, on some servers this will prevent all PHP pages from working (you will see errors when you look at pages) so you'll have to remove the .htaccess file. "; +$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.'; $string['pass'] = 'Pass'; $string['phpversion'] = 'PHP version'; $string['phpversionerror'] = 'PHP version must be at least 4.1.0';