diff --git a/include/functions.inc.php b/include/functions.inc.php
index ada6b22cf..5f450ab7e 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -94,7 +94,11 @@ function redirect($location, $message = null) {
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
global $dbh, $error, $SELF;
$id = "sql-" . count($_SESSION["messages"]);
- $sql = ($query ? " " . lang('SQL command') . "" . htmlspecialchars($query) . '
' . lang('Edit') . '' : "");
+ $sql = "";
+ if ($query) {
+ $sql = " " . lang('SQL command') . "" . htmlspecialchars($query) . '
' . lang('Edit') . '';
+ $_SESSION["history"][] = $query;
+ }
if ($execute) {
$failed = !$dbh->query($query);
}
diff --git a/sql.inc.php b/sql.inc.php
index 452108bf4..74454ffc0 100644
--- a/sql.inc.php
+++ b/sql.inc.php
@@ -67,7 +67,7 @@
?>