From 840c543df8fa62a0417e53c632751f03185f17a4 Mon Sep 17 00:00:00 2001 From: Ian C Date: Fri, 22 Jun 2018 13:27:11 +0000 Subject: Fixed up data access pages. --- www/add.php | 2 +- www/common.php | 4 ++++ www/edit.php | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/www/add.php b/www/add.php index d70fca9..fe21344 100644 --- a/www/add.php +++ b/www/add.php @@ -45,7 +45,7 @@ try } catch(PDOException $e) { - result["error"] = "DB error:" . $e->getMessage(); + $result["error"] = "DB error:" . $e->getMessage(); } header("Content-type:application/json"); diff --git a/www/common.php b/www/common.php index 52971eb..a86d7b7 100644 --- a/www/common.php +++ b/www/common.php @@ -19,10 +19,14 @@ function ConnectDB() { + global $config; + $pdo = new PDO("mysql:host=localhost;dbname={$config["dbname"]}", $config["dbuser"], $config["dbpassword"]); + $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $pdo; } + ?> diff --git a/www/edit.php b/www/edit.php index 1c61148..9e78e88 100644 --- a/www/edit.php +++ b/www/edit.php @@ -35,7 +35,7 @@ try $cmd = $db->prepare("UPDATE pm_store " . "set description=:description, " . "username=:username, " . - "password=:password) where id = :id"); + "password=:password where id = :id"); $cmd->bindParam(":id", $id); $cmd->bindParam(":description", $description); $cmd->bindParam(":username", $username); @@ -48,7 +48,7 @@ try } catch(PDOException $e) { - result["error"] = "DB error:" . $e->getMessage(); + $result["error"] = "DB error:" . $e->getMessage(); } header("Content-type:application/json"); -- cgit v1.2.3