bug 968089 mysqli fix

This commit is contained in:
Marc Delisle
2004-06-10 17:17:58 +00:00
parent f776451297
commit 041245c24d
3 changed files with 31 additions and 10 deletions

View File

@@ -7,11 +7,9 @@ $Source$
2004-06-10 Marc Delisle <lem9@users.sourceforge.net> 2004-06-10 Marc Delisle <lem9@users.sourceforge.net>
* libraries/auth/config.auth.lib.php, libraries/dbi/mysql.dbi.lib.php, * libraries/auth/config.auth.lib.php, libraries/dbi/mysql.dbi.lib.php,
libraries/dbi/mysql.dbi.lib.php,
lang/*: bug 968089: catch error when server is not responding lang/*: bug 968089: catch error when server is not responding
and show an appropriate message and show an appropriate message
TODO: for mysqli
* left.php: undefined variable * left.php: undefined variable
2004-06-09 Alexander M. Turek <me@derrabus.de> 2004-06-09 Alexander M. Turek <me@derrabus.de>

View File

@@ -110,8 +110,10 @@ h1 {font-family: <?php echo $right_font_family; ?>; font-size: <?php echo
// (note: it's true that they could have a badly typed host name, but // (note: it's true that they could have a badly typed host name, but
// anyway the current $strAccessDeniedExplanation tells that the server // anyway the current $strAccessDeniedExplanation tells that the server
// rejected the connection, which is not really what happened) // rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
if (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2003)) { if (!isset($GLOBALS['errno']) || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002) && $GLOBALS['errno'] != 2003) {
echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n"; echo '<p>' . $GLOBALS['strAccessDeniedExplanation'] . '</p>' . "\n";
} }
PMA_mysqlDie($conn_error, ''); PMA_mysqlDie($conn_error, '');

View File

@@ -177,18 +177,39 @@ function PMA_DBI_free_result($result) {
} }
function PMA_DBI_getError($link = NULL) { function PMA_DBI_getError($link = NULL) {
unset($GLOBALS['errno']);
if (empty($link)) { if (empty($link)) {
if (isset($GLOBALS['userlink'])) { if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink']; $link = $GLOBALS['userlink'];
} else { // Do not stop now. We still can get the error code
return FALSE; // with mysqli_connect_errno()
// } else {
// return FALSE;
} }
} }
$error = mysqli_errno($link);
if ($error && PMA_MYSQL_INT_VERSION >= 40100) { if (mysqli_connect_errno()) {
$error = '#' . ((string) $error) . ' - ' . mysqli_error($link); $error = mysqli_connect_errno();
$error_message = mysqli_connect_error();
} elseif (mysqli_errno($link)) {
$error = mysqli_errno($link);
$error_message = mysqli_error($link);
}
// keep the error number for further check after the call to PMA_DBI_getError()
if ($error) {
$GLOBALS['errno'] = $error;
} else {
return FALSE;
}
if ($error && $error == 2002) {
$error = '#' . ((string) $error) . ' - ' . $GLOBALS['strServerNotResponding'];
} elseif ($error && PMA_MYSQL_INT_VERSION >= 40100) {
$error = '#' . ((string) $error) . ' - ' . $error_message;
} elseif ($error) { } elseif ($error) {
$error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysqli_error($link)); $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset($error_message);
} }
return $error; return $error;
} }