summaryrefslogtreecommitdiff
path: root/includes/database.mysqli.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2006-02-15 21:39:51 +0000
committerDries Buytaert <dries@buytaert.net>2006-02-15 21:39:51 +0000
commiteaa10cd724e42c873d9c1def9a0e3e0a34e06428 (patch)
treecf7e54e9647dc6f631d6b614d981fe3e564e33f1 /includes/database.mysqli.inc
parent5a5233e88c3398b0992d7e94bd474141547cce86 (diff)
downloadbrdo-eaa10cd724e42c873d9c1def9a0e3e0a34e06428.tar.gz
brdo-eaa10cd724e42c873d9c1def9a0e3e0a34e06428.tar.bz2
- Patch #47919 by Thomas: fixed various glitches with MySQLi's error handling and non-standard port support..
Diffstat (limited to 'includes/database.mysqli.inc')
-rw-r--r--includes/database.mysqli.inc14
1 files changed, 4 insertions, 10 deletions
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', '<p>This either means that the username and password information in your <code>settings.php</code> 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.</p>
+ print theme('maintenance_page', '<p>This either means that the username and password information in your <code>settings.php</code> 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.</p>
<p>The MySQL error was: '. theme('placeholder', mysqli_error($connection)) .'.</p>
<p>Currently, the username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p>
<ul>
@@ -61,8 +56,7 @@ function db_connect($url) {
<p>For more help, see the <a href="http://drupal.org/node/258">Installation and upgrading handbook</a>. If you are unsure what these terms mean you should probably contact your hosting provider.</p>');
exit;
}
-
- if (!mysqli_select_db($connection, substr($url['path'], 1))) {
+ else if (mysqli_connect_errno() == 1044) {
drupal_maintenance_theme();
drupal_set_title('Unable to select database');
print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.</p>