From 64ea56164ad8f0f2cee5676f84d2d8f064e986e1 Mon Sep 17 00:00:00 2001
From: Marius Cramer <m.cramer@pixcept.de>
Date: Tue, 29 Jul 2014 11:55:13 -0400
Subject: [PATCH] Improved input validation

---
 server/lib/classes/db_mysql.inc.php |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/server/lib/classes/db_mysql.inc.php b/server/lib/classes/db_mysql.inc.php
index f5ce39c..d8bfbea 100644
--- a/server/lib/classes/db_mysql.inc.php
+++ b/server/lib/classes/db_mysql.inc.php
@@ -101,8 +101,8 @@
     }
 	*/
 		if(mysqli_connect_error()) {
-			$this->errorNumber = mysqli_connect_errno();
-			$this->errorMessage = mysqli_connect_error();
+			$this->errorNumber = $this->connect_errno;
+			$this->errorMessage = $this->connect_error;
 		} else {
 			$this->errorNumber = mysqli_errno($this);
 			$this->errorMessage = mysqli_error($this);
@@ -137,8 +137,8 @@
 			$ok = $this->ping();
 			if(!$ok) {
 				if(!$this->real_connect($this->dbHost, $this->dbUser, $this->dbPass, $this->dbName)) {
+					$this->updateError('DB::query -> reconnect');
 					if($try > 9) {
-						$this->updateError('DB::query -> reconnect');
 						return false;
 					} else {
 						sleep(($try > 7 ? 5 : 1));
@@ -150,7 +150,7 @@
 			}
 		} while($ok == false);
 		$this->queryId = parent::query($queryString);
-		$this->updateError('DB::query('.$queryString.') -> mysqli_query');
+		 if(!$this->queryId) $this->updateError('DB::query('.$queryString.') -> mysqli_query');
 		if(!$this->queryId) {
 			return false;
 		}
@@ -184,9 +184,9 @@
 	// returns the next record in an array
 	public function nextRecord() {
 		$this->record = $this->queryId->fetch_assoc();
-		$this->updateError('DB::nextRecord()-> mysql_fetch_array');
 		if(!$this->record || !is_array($this->record))
 		{
+			$this->updateError('DB::nextRecord()-> mysql_fetch_array');
 			return false;
 		}
 		$this->currentRow++;

--
Gitblit v1.9.1