diff --git a/ChangeLog b/ChangeLog
index 71259d40d..c7c97a67a 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
+2004-10-21 Michael Keck
+ * libraries/common.lib.php: feature request #1036254
+ Add a link by MySQL-Error #1062 - Duplicate entry
+
2004-10-21 Michal Čihař
* [too many files to mention]: Cleanup of message displaying and
navigation reloading. Messages are now displayed bellow tabs (RFE
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 19d4ce7f9..ab789809b 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -641,7 +641,10 @@ if ($is_minimum_common == FALSE) {
. ' ' . $formatted_sql . "\n"
. '
' . "\n";
} // end if
+
+ $tmp_mysql_error = ''; // for saving the original $error_message
if (!empty($error_message)) {
+ $tmp_mysql_error = strtolower($error_message); // save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\015\012)|(\015)|(\012)){3,}@", "\n\n", $error_message);
}
@@ -664,7 +667,27 @@ if ($is_minimum_common == FALSE) {
echo '' . "\n"
. $error_message . "\n"
- . '
' . "\n";
+ . '
' . "\n";
+
+ // feature request #1036254:
+ // Add a link by MySQL-Error #1062 - Duplicate entry
+ // 2004-10-20 by mk.keck
+ if (strstr($tmp_mysql_error,"duplicate")) {
+ // explode the entry and the column
+ $arr_mysql_val_key = explode('entry \'',$tmp_mysql_error);
+ $arr_mysql_val_key = explode('\' for key',$arr_mysql_val_key[1]);
+ // get the duplicate value
+ $string_duplicate_val = trim(strtolower($arr_mysql_val_key[0]));
+ // get the field name ...
+ $string_duplicate_key = mysql_result(mysql_query("SHOW FIELDS FROM " . $table), ($arr_mysql_val_key[1]-1), 0);
+ $duplicate_sql_query = "SELECT * FROM " . $table . " WHERE " . $string_duplicate_key . " LIKE '" . $string_duplicate_val . "'";
+ echo ' ' . "\n";
+ } // end of show duplicate entry
+
echo '';
if (!empty($back_url) && $exit) {