Permalink
Browse files

Simplify SQL syntax errors everywhere

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1276 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
1 parent 0477032 commit c1130ed5992782b7a8f1801e30bb2a5e1e3c6688 jakubvrana committed Dec 17, 2009
@@ -30,7 +30,7 @@
}
$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();
@@ -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) {
@@ -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
@@ -144,7 +144,7 @@
$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 @@
$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";
View
@@ -63,7 +63,7 @@
$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;
}
@@ -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());

0 comments on commit c1130ed

Please sign in to comment.