From 28aadecc6c261012471d242354782d5e15d24e55 Mon Sep 17 00:00:00 2001 From: r4sas Date: Sun, 28 Aug 2022 20:25:59 +0000 Subject: [PATCH] fix unbuffered query execution --- views/add.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/views/add.php b/views/add.php index 2b2c81c..f67a1b4 100644 --- a/views/add.php +++ b/views/add.php @@ -90,7 +90,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { } else { $base32 = $util->b32from64($parsed["b64"]); - if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) { + $STH = !$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)'); + if (!$STH->execute([$domain, $parsed["b64"], $base32])) { $result["error"] = "Error happened while inserting record to database. Please try again later."; } else { @@ -119,7 +120,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { } else { $base32 = $util->b32from64($parsed["b64"]); - if (!$pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?')->execute([$parsed["b64"], $base32, $domain])) { + $STH = $pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?'); + if (!$STH->execute([$parsed["b64"], $base32, $domain])) { $result["error"] = "Error happened while updating record in database. Please try again later."; } else { @@ -158,7 +160,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { } else { $base32 = $util->b32from64($parsed["b64"]); - if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) { + $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)'); + if (!$STH->execute([$domain, $parsed["b64"], $base32])) { $result["error"] = "Error happened while updating record in database. Please try again later."; } else { @@ -223,7 +226,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { $base32 = $util->b32from64($parsed["b64"]); /* Adding to database 2LD domain */ - if (!$pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)')->execute([$domain, $parsed["b64"], $base32])) { + $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)'); + if (!$STH->execute([$domain, $parsed["b64"], $base32])) { $result["error"] = "Error happened while inserting record to database. Please try again later."; } else {