]> git.joonet.de Git - adminer.git/commitdiff
Simplify SQL syntax errors everywhere
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 17 Dec 2009 15:31:24 +0000 (15:31 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Thu, 17 Dec 2009 15:31:24 +0000 (15:31 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1276 7c3ca157-0c34-0410-bff1-cbf682f78f5c

adminer/call.inc.php
adminer/include/functions.inc.php
adminer/include/mysql.inc.php
adminer/select.inc.php
adminer/sql.inc.php
adminer/table.inc.php

index f9871d53527c50524b0f6c39f69c6c71c0ad2756..8753e90e9a12cb30a69580a9bd99d9b9169d5d36 100644 (file)
@@ -30,7 +30,7 @@ if (!$error && $_POST) {
        }
        $result = $connection->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")");
        if (!$result) {
-               echo "<p class='error'>" . h($connection->error) . "\n";
+               echo "<p class='error'>" . error() . "\n";
        } else {
                do {
                        $result = $connection->store_result();
index 21d1c13ee6f0eb568a7a02d13859450b8e13f217..dba76517b1cdde1b05064b8c2f32175b9133a548 100644 (file)
@@ -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) {
index 3b3dcc56ca6df19d84114d647d98f822642b0d1d..11e495f1783375599bf0c6699f177acd931dbe14 100644 (file)
@@ -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
index 4531fa6b5d5b568af1bd1691e3a964a2e068ed7d..b7d4917fba7eeb7b49ce9718d3cb382d291f361b 100644 (file)
@@ -144,7 +144,7 @@ if (isset($rights["insert"])) {
 $adminer->selectLinks($table_status, $set);
 
 if (!$columns) {
-       echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . h($connection->error)) . ".\n";
+       echo "<p class='error'>" . lang('Unable to select the table') . ($fields ? "" : ": " . error()) . ".\n";
 } else {
        echo "<form action='' id='form'>\n";
        echo "<div style='display: none;'>";
@@ -165,7 +165,7 @@ if (!$columns) {
        
        $result = $connection->query($query);
        if (!$result) {
-               echo "<p class='error'>" . h($connection->error) . "\n";
+               echo "<p class='error'>" . error() . "\n";
        } else {
                $email_fields = array();
                echo "<form action='' method='post' enctype='multipart/form-data'>\n";
index 61d309d1957dfef207a20ffdab0d2754aeedae92..0045b2e5d1b064926e6b0b639994c6e0d9e23f22 100644 (file)
@@ -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 "<p class='error'>" . lang('Error in query') . ": " . h(preg_replace('~^You have an error.*syntax to use~U', "Syntax error", $connection->error)) . "\n";
+                                                       echo "<p class='error'>" . lang('Error in query') . ": " . error() . "\n";
                                                        if ($_POST["error_stops"]) {
                                                                break;
                                                        }
index 94563932a883e7277d9bbba115b5375c53c5b2c9..544f5424199ec7c5cd0a8b0d10f703cc866b7971 100644 (file)
@@ -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());