From c1130ed5992782b7a8f1801e30bb2a5e1e3c6688 Mon Sep 17 00:00:00 2001 From: jakubvrana Date: Thu, 17 Dec 2009 15:31:24 +0000 Subject: [PATCH] Simplify SQL syntax errors everywhere git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1276 7c3ca157-0c34-0410-bff1-cbf682f78f5c --- adminer/call.inc.php | 2 +- adminer/include/functions.inc.php | 2 +- adminer/include/mysql.inc.php | 8 ++++++++ adminer/select.inc.php | 4 ++-- adminer/sql.inc.php | 2 +- adminer/table.inc.php | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/adminer/call.inc.php b/adminer/call.inc.php index f9871d53..8753e90e 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -30,7 +30,7 @@ if (!$error && $_POST) { } $result = $connection->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")"); if (!$result) { - echo "

" . h($connection->error) . "\n"; + echo "

" . error() . "\n"; } else { do { $result = $connection->store_result(); diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 21d1c13e..dba76517 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -246,7 +246,7 @@ function query_redirect($query, $location, $message, $redirect = true, $execute $sql = $adminer->messageQuery($query); } if ($failed) { - $error = h($connection->error) . $sql; + $error = error() . $sql; return false; } if ($redirect) { diff --git a/adminer/include/mysql.inc.php b/adminer/include/mysql.inc.php index 3b3dcc56..11e495f1 100644 --- a/adminer/include/mysql.inc.php +++ b/adminer/include/mysql.inc.php @@ -372,6 +372,14 @@ function information_schema($db) { return ($connection->server_info >= 5 && $db == "information_schema"); } +/** Get escaped error message +* @return string +*/ +function error() { + global $connection; + return h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error)); +} + /** Return expression for binary comparison * @param string * @return string diff --git a/adminer/select.inc.php b/adminer/select.inc.php index 4531fa6b..b7d4917f 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -144,7 +144,7 @@ if (isset($rights["insert"])) { $adminer->selectLinks($table_status, $set); if (!$columns) { - echo "

" . lang('Unable to select the table') . ($fields ? "" : ": " . h($connection->error)) . ".\n"; + echo "

" . lang('Unable to select the table') . ($fields ? "" : ": " . error()) . ".\n"; } else { echo "

\n"; echo "
"; @@ -165,7 +165,7 @@ if (!$columns) { $result = $connection->query($query); if (!$result) { - echo "

" . h($connection->error) . "\n"; + echo "

" . error() . "\n"; } else { $email_fields = array(); echo "\n"; diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index 61d309d1..0045b2e5 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -63,7 +63,7 @@ if (!$error && $_POST) { $start = explode(" ", microtime()); // microtime(true) is available since PHP 5 //! don't allow changing of character_set_results, convert encoding of displayed query if (!$connection->multi_query($q)) { - echo "

" . lang('Error in query') . ": " . h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error)) . "\n"; + echo "

" . lang('Error in query') . ": " . error() . "\n"; if ($_POST["error_stops"]) { break; } diff --git a/adminer/table.inc.php b/adminer/table.inc.php index 94563932..544f5424 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -2,7 +2,7 @@ $TABLE = $_GET["table"]; $fields = fields($TABLE); if (!$fields) { - $error = h($connection->error); + $error = error(); } $table_status = ($fields ? table_status($TABLE) : array());