changeset 1112:0eca3f1b1d48

Improve error handling.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 27 Sep 2017 14:16:11 +0300
parents ed9270f65a37
children d5847f016de5
files admajax.php
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/admajax.php	Sun Feb 05 03:49:38 2017 +0200
+++ b/admajax.php	Wed Sep 27 14:16:11 2017 +0300
@@ -1279,8 +1279,7 @@
           "  <div class=\"ctrlInfo\">Controls for competition showing mode. Select and activate desired compo, then ".
           "hit 'Next entry' to activate the first entry to show. <b>Notice! You need to have generated 'show positions' ".
           "before starting compos!</b></div>\n".
-          "  <div class=\"ctrlDBox1\">\n".
-          stGetFormOptionListStart("ctrlCompoList", "    ", TRUE);
+          "  <div class=\"ctrlDBox1\">\n";
 
         $sql =
           "SELECT compos.*, ".
@@ -1293,16 +1292,19 @@
         $currCompoID = stGetDisplayVar("compoID");
         if (($res = stExecSQL($sql)) !== false)
         {
+          echo stGetFormOptionListStart("ctrlCompoList", "    ", TRUE);
           foreach ($res as $item)
           {
             echo stGetFormOptionListItem("     ", $item["id"],
               ($item["id"] == $currCompoID),
               sprintf("%-20s (%d entries)", substr($item["name"], 0, 20), $item["nentries"]));
           }
+          echo stGetFormOptionListEnd("    ", TRUE);
         }
+        else
+          echo "ERROR";
 
         echo
-          stGetFormOptionListEnd("    ", TRUE).
           "    <div class=\"ctrlButtons\">\n".
           "      ".stGetFormButtonInput("setcompo", "", "", "Change compo", "activateCompo()")."\n".
           "    </div>\n".
@@ -1334,13 +1336,18 @@
           "<hr />\n";
 
         $sql = "SELECT * FROM news ORDER BY utime DESC";
-        foreach (stExecSQL($sql) as $item)
+        if (($res = stExecSQL($sql)) !== false)
         {
-          echo
-            "<div id=\"news".$item["id"]."\" class=\"newsItem\">\n".
-            stGetNewsItemData($item["id"], $item, "ne").
-            "</div>\n";
+          foreach ($res as $item)
+          {
+            echo
+              "<div id=\"news".$item["id"]."\" class=\"newsItem\">\n".
+              stGetNewsItemData($item["id"], $item, "ne").
+              "</div>\n";
+          }
         }
+        else
+          echo "ERROR";
         break;
 
       case "newsitem":