Relational algebra bug
diff --git a/php/request.php b/php/request.php
index 58201ae..12f0f7d 100644
--- a/php/request.php
+++ b/php/request.php
@@ -4,7 +4,7 @@
// Do the query
$queries = [""];
- $victimid = "ANY (SELECT quimata FROM users WHERE id=".(int)$_POST['user_id'].")";
+ $victimid = "ANY (SELECT quimata FROM (SELECT * FROM users) AS victims WHERE id=".(int)$_POST['user_id'].")";
if ($_POST['msg'] == "REQ KILL") $queries = ["UPDATE users SET requested=1 WHERE id=".$victimid]; // request kill
if ($_POST['msg'] == "REQ DEAD") $queries = ["UPDATE users SET requested=2 WHERE quimata=".(int)$_POST['user_id']]; // request dead
@@ -16,6 +16,6 @@
// Fetch the information of the user
foreach ($queries as $query) {
if ($query != "" and $result = query($query)) echo $query;
- else die("Wrong query: " . $query);
+ else die("Query failed: " . $result);
}
?>
diff --git a/php/utils.php b/php/utils.php
index ae0cb5b..1e20ebf 100644
--- a/php/utils.php
+++ b/php/utils.php
@@ -20,7 +20,7 @@
$conn->set_charset("utf8");
// Execute query and save result
- $result = $conn->query($query);
+ if (!$result = $conn->query($query)) $result = $conn->error;
// Close the connection
$conn->close();
@@ -54,7 +54,7 @@
}
$result->close();
} else {
- die("Wrong query: " . $query);
+ die("Query failed: " . $query);
}
if ($id > 0) return $users[0];