num_rows < 1) { JError("you cannot edit that alarm"); } //Check if stream is allowed $sql = "SELECT `name` FROM `stream` WHERE `dev_id`=$deviceid AND `id`=$stream"; $query = ExecQuery($mysqli, $sql); if($query->num_rows < 1) { JError("you cannot use that stream"); } //Remove seconds $time = substr($time, 0, 5); //Check time if(!preg_match("/(2[0-3]|[01][0-9]):([0-5][0-9])/", $time)) { JError("invalid time"); } $time .= ":00"; //update $sql = "UPDATE `alarm` SET `name`='$name', `time`='$time', `stream`=$stream WHERE `id`=$id"; ExecQuery($mysqli, $sql); JSuccess("true"); ?>