try {
            mysql_connect("localhost", "root", "root") or die("Unable to connect to the server: " . mysql_error());
            // NAPOMENA: podesiti odgovarajući username i password
            mysql_set_charset("utf8");
            mysql_select_db("iot_dashboard_db") or die("Unable to connect to the database: " . mysql_error());
            // NAPOMENA: Ukoliko se promijeni, podesiti odgovarajući naziv baze
            $q = mysql_query("SELECT flag FROM widget_change WHERE flag = 1;") or die("Error in query: " . mysql_error());
            $row = mysql_fetch_assoc($q);
            $flag = $row['flag'];
            mysql_close();
            if ($flag == 1) {
                try {
                    mysql_connect("localhost", "root", "root") or die("Unable to connect to the server: " . mysql_error());
                    // NAPOMENA: podesiti odgovarajući username i password
                    mysql_set_charset("utf8");
                    mysql_select_db("iot_dashboard_db") or die("Unable to connect to the database: " . mysql_error());
                    // NAPOMENA: Ukoliko se promijeni, podesiti odgovarajući naziv baze
                    $q = mysql_query("UPDATE widget_change SET flag = '0';") or die("Error in query: " . mysql_error());
                    mysql_close();
                } catch (Exception $e) {
                    echo 'Caught exception: ', $e->getMessage(), "\n";
                }
                $mqtt->disconnect();
                break;
            }
        } catch (Exception $e) {
            echo 'Caught exception: ', $e->getMessage(), "\n";
        }
    }
    $mqtt->close();
}