From 49fcd5d983e143526bb71b21ce9ff5c16b931e4d Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Tue, 17 Oct 2017 13:43:02 +0200 Subject: [PATCH] fix: no more errors when alliance is in no wars --- GameEngine/Database.php | 42 +++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 9e91439f..10610257 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -1789,15 +1789,18 @@ class MYSQLi_DB { $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '$type' AND accepted = '1' OR alli2 = '$aid' AND type = '$type' AND accepted = '1'"; $array = $this->query_return($q); $text = ""; - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } + + if ($array) { + foreach($array as $row){ + if($row['alli1'] == $aid){ + $alliance = $this->getAlliance($row['alli2']); + }elseif($row['alli2'] == $aid){ + $alliance = $this->getAlliance($row['alli1']); + } + $text .= ""; + $text .= "".$alliance['tag']."
"; + } + } if(strlen($text) == 0){ $text = "-
"; } @@ -1809,15 +1812,18 @@ class MYSQLi_DB { $q = "SELECT * FROM ".TB_PREFIX."diplomacy WHERE alli1 = '$aid' AND type = '3' OR alli2 = '$aid' AND type = '3' AND accepted = '1'"; $array = $this->query_return($q); $text = ""; - foreach($array as $row){ - if($row['alli1'] == $aid){ - $alliance = $this->getAlliance($row['alli2']); - }elseif($row['alli2'] == $aid){ - $alliance = $this->getAlliance($row['alli1']); - } - $text .= ""; - $text .= "".$alliance['tag']."
"; - } + + if ($array) { + foreach($array as $row){ + if($row['alli1'] == $aid){ + $alliance = $this->getAlliance($row['alli2']); + }elseif($row['alli2'] == $aid){ + $alliance = $this->getAlliance($row['alli1']); + } + $text .= ""; + $text .= "".$alliance['tag']."
"; + } + } if(strlen($text) == 0){ $text = "-
"; }