From 1386e00ce330646cc8631c1f0ecf2aa2ef6325f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steffen=20Schro=CC=88der?= Date: Wed, 19 Mar 2014 11:36:57 +0100 Subject: [PATCH] mysqli error handling --- application/plugins/ServerRanking.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/application/plugins/ServerRanking.php b/application/plugins/ServerRanking.php index a9574411..20f02f22 100644 --- a/application/plugins/ServerRanking.php +++ b/application/plugins/ServerRanking.php @@ -357,14 +357,18 @@ class ServerRankingPlugin implements Plugin, CallbackListener, CommandListener { $mysqli = $this->maniaControl->database->mysqli; $result = $mysqli->query('SELECT * FROM ' . self::TABLE_RANK . ' WHERE PlayerIndex=' . $player->index); - if ($result->num_rows > 0) { - $row = $result->fetch_array(); - $result->free_result(); - return Rank::fromArray($row); - } else { + if ($mysqli->error) { + trigger_error($mysqli->error); + return null; + } + if ($result->num_rows <= 0) { $result->free_result(); return null; } + + $row = $result->fetch_array(); + $result->free_result(); + return Rank::fromArray($row); } /**