+ $mysqlOldClient = version_compare( mysql_get_client_info(), "4.1.0", "lt" );
+ if( $mysqlOldClient ) {
+ print "<li><b>PHP is linked with old MySQL client libraries. If you are
+ using a MySQL 4.1 server and have problems connecting to the database,
+ see <a href='http://dev.mysql.com/doc/mysql/en/old-client.html'
+ >http://dev.mysql.com/doc/mysql/en/old-client.html</a> for help.</b></li>\n";
+ }
+ $dbc = new $dbclass;
+
+ if( $conf->DBtype == 'mysql' ) {
+ $ok = true; # Let's be optimistic
+
+ # Decide if we're going to use the superuser or the regular database user
+ if( $conf->RootPW == '-' ) {
+ # Regular user
+ $conf->Root = false;
+ $db_user = $wgDBuser;
+ $db_pass = $wgDBpassword;
+ } else {
+ # Superuser
+ $conf->Root = true;
+ $db_user = $conf->RootUser;
+ $db_pass = $conf->RootPW;
+ }
+
+ # Attempt to connect
+ echo( "<li>Attempting to connect to database server as $db_user..." );
+ $wgDatabase = Database::newFromParams( $wgDBserver, $db_user, $db_pass, '', 1 );
+
+ # Check the connection and respond to errors
+ if( $wgDatabase->isOpen() ) {
+ # Seems OK
+ $ok = true;
+ $wgDBadminuser = $db_user;
+ $wgDBadminpassword = $wgDBpassword;
+ echo( "success.</li>\n" );
+ $wgDatabase->ignoreErrors( true );
+ $myver = mysql_get_server_info( $wgDatabase->mConn );
+ } else {
+ # There were errors, report them and back out
+ $ok = false;
+ $errno = mysql_errno();
+ $errtx = htmlspecialchars( mysql_error() );
+ switch( $errno ) {
+ case 1045:
+ case 2000:
+ echo( "failed due to authentication errors. Check passwords.</li>" );
+ if( $conf->Root ) {
+ # The superuser details are wrong
+ $errs["RootUser"] = "Check username";
+ $errs["RootPW"] = "and password";
+ } else {
+ # The regular user details are wrong
+ $errs["DBuser"] = "Check username";
+ $errs["DBpassword"] = "and password";
+ }
+ break;
+ case 2002:
+ case 2003:
+ default:
+ # General connection problem
+ echo( "failed with error [$errno] $errtx.</li>\n" );
+ $errs["DBserver"] = "Connection failed";
+ break;
+ } # switch
+ } #conn. att.
+
+ if( !$ok ) { continue; }