diff --git a/ChangeLog b/ChangeLog index ddc9eb236..b062b0fe2 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,13 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-06-10 Marc Delisle + * libraries/auth/config.auth.lib.php, libraries/dbi/mysql.dbi.lib.php, + lang/*: bug 968089: catch error when server is not responding + and show an appropriate message + + TODO: for mysqli + 2004-06-09 Alexander M. Turek ### 2.5.7 released from MAINT_2_5 branch. diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index e94a7c4f6..a8c86f2f5 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -182,18 +182,40 @@ function PMA_DBI_free_result($result) { } function PMA_DBI_getError($link = NULL) { + unset($GLOBALS['errno']); if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; - } else { - return FALSE; - } + +// Do not stop now. On the initial connection, we don't have a $link, +// we don't have a $GLOBALS['userlink'], but we can catch the error code +// } else { +// return FALSE; + } } - $error = mysql_errno($link); - if ($error && PMA_MYSQL_INT_VERSION >= 40100) { - $error = '#' . ((string) $error) . ' - ' . mysql_error($link); + + if (mysql_errno()) { + $error = mysql_errno(); + $error_message = mysql_error(); + } else { + $error = mysql_errno($link); + $error_message = mysql_error($link); + } + + // keep the error number for further check after the call to PMA_DBI_getError() + if ($error) { + $GLOBALS['errno'] = $error; + } else { + return FALSE; + } + +// Some errors messages cannot be obtained by mysql_error() + if ($error && $error == 2003) { + $error = '#' . ((string) $error) . ' - ' . $GLOBALS['strServerNotResponding']; + } elseif ($error && PMA_MYSQL_INT_VERSION >= 40100) { + $error = '#' . ((string) $error) . ' - ' . $error_message; } elseif ($error) { - $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysql_error($link)); + $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset($error_message); } return $error; }