From: Brian Flowers Date: Sat, 5 Nov 2016 17:03:13 +0000 (-0400) Subject: Additional bugfixes on error checking X-Git-Url: http://git.slightlycyberpunk.com%2C%20git.slightlycyberpunk.com/git/?a=commitdiff_plain;h=f63890d4f9bf12dcc5465fad9a746ff742d74e2b;p=bdsm-web.git Additional bugfixes on error checking --- 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();