From f63890d4f9bf12dcc5465fad9a746ff742d74e2b Mon Sep 17 00:00:00 2001 From: Brian Flowers Date: Sat, 5 Nov 2016 13:03:13 -0400 Subject: [PATCH] Additional bugfixes on error checking --- TODO | 3 +++ configure.php | 19 +++++++++++++++++-- graph.php | 6 ++++-- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 TODO diff --git a/TODO b/TODO new file mode 100644 index 0000000..4834be2 --- /dev/null +++ b/TODO @@ -0,0 +1,3 @@ +TODO + - Add timings to graphs + - Add charts of other info \ No newline at end of file diff --git a/configure.php b/configure.php index 65970f5..6116788 100755 --- a/configure.php +++ b/configure.php @@ -19,11 +19,22 @@ if( $db->errorInfo()[0] == "HY000" ) "attribute VARCHAR(128), name VARCHAR(128), ". "graph integer, maximum integer, minimum integer, ". "duration integer, primary key (host, attribute));"; - $db->query($query); + if( ! $db->query($query) ) + { + print_r($db->errorInfo); + die(); + } $result = $db->query("SELECT * FROM bdsmweb;"); } +if( !$result ) +{ + echo "Error selecting table bdsmweb
"; + print_r($db->errorInfo()); + die(); +} + if( isset($_POST) ) { foreach( array_keys($_POST) as $key ) @@ -100,7 +111,11 @@ foreach ($hosts as $host) foreach($attributes as $attribute) { $result = $db->query("SELECT * FROM bdsmweb WHERE host='$host' AND attribute='$attribute'"); - $values = $result->fetch(); + if( $result ) + $values = $result->fetch(); + else + $values = Array(); + echo " "; echo " $attribute"; echo " "; diff --git a/graph.php b/graph.php index e5ff497..89af683 100644 --- a/graph.php +++ b/graph.php @@ -58,10 +58,12 @@ if( !in_array($host, $hosts) ) context.lineWidth = 2; query("SELECT attribute, name FROM bdsmweb WHERE host='$host' AND graph=1;"); - if( !$result ) + if( ! $result ) { - echo "Error: No measurements found in database file /home/bdsm/etc/bdsm/bdsm.db for host $host"; + echo "
"; + echo "Error: No configuration found in database file /home/bdsm/etc/bdsm/bdsm.db for host $host
"; echo "Query: SELECT attribute, name FROM bdsmweb WHERE host='$host' AND graph=1;"; + die(); } $attributes = Array(); -- 1.8.3.1