From eaa10cd724e42c873d9c1def9a0e3e0a34e06428 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 15 Feb 2006 21:39:51 +0000 Subject: - Patch #47919 by Thomas: fixed various glitches with MySQLi's error handling and non-standard port support.. --- includes/database.mysqli.inc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'includes') diff --git a/includes/database.mysqli.inc b/includes/database.mysqli.inc index 68dcc8d3e..d9cbb5180 100644 --- a/includes/database.mysqli.inc +++ b/includes/database.mysqli.inc @@ -38,18 +38,13 @@ function db_connect($url) { $url['host'] = urldecode($url['host']); $url['path'] = urldecode($url['path']); - // Allow for non-standard MySQL port. - if (isset($url['port'])) { - $url['host'] = $url['host'] .':'. $url['port']; - } - $connection = mysqli_init(); - @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), NULL, NULL, MYSQLI_CLIENT_FOUND_ROWS); + @mysqli_real_connect($connection, $url['host'], $url['user'], $url['pass'], substr($url['path'], 1), $url['port'], NULL, MYSQLI_CLIENT_FOUND_ROWS); - if (!$connection) { + if (mysqli_connect_errno() == 2003) { drupal_maintenance_theme(); drupal_set_title('Unable to connect to database server'); - print theme('maintenance_page', '

This either means that the username and password information in your settings.php file is incorrect or we can\'t contact the MySQL database server through the mysqli libraries. This could mean your hosting provider\'s database server is down, or your PHP is not compiled with mysqli.

+ print theme('maintenance_page', '

This either means that the username and password information in your settings.php file is incorrect or we can\'t contact the MySQL database server through the mysqli libraries. This could also mean your hosting provider\'s database server is down.

The MySQL error was: '. theme('placeholder', mysqli_error($connection)) .'.

Currently, the username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.