From 63eef9822f21bf54a0bbde2a12842fdb77ab8fec Mon Sep 17 00:00:00 2001
From: Imran Hussain <imranh@sucs.org>
Date: Fri, 25 Apr 2014 13:55:00 +0000
Subject: [PATCH] Fixed warnings in the library section

---
 components/library.php | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/components/library.php b/components/library.php
index b5b92a1..258596a 100644
--- a/components/library.php
+++ b/components/library.php
@@ -35,8 +35,14 @@ if (isset($_REQUEST['search']) && (trim($_REQUEST['search']) != "")) {
 	if (isset($pathlist[$library_index + 2])) {
 		$tag = $pathlist[$library_index + 2];
 		// we're displaying books with a specific tag
-		$categories = $DB->GetOne("SELECT count(name) FROM bookcategories WHERE name=?", array($tag));		
-		if ($categories['count'] == 1) {
+		//The following line doesn't do what I think you think it does.
+		//It will return a string if the tag exists, "1" and "0" when a tag doesn't exist
+		$categories = $DB->GetOne("SELECT count(name) FROM bookcategories WHERE name=?", array($tag));
+		//debug stuff, LOOK IT'S A STRING
+		//var_dump($categories);
+		//if ($categories['count'] == 1) {
+		//$categories is not an aray, it's a string, yeah i know == != good_programing
+		if ($categories == 1) {
 			$mode = "tagdisplay";
 			$query = "SELECT b.id, b.title FROM books AS b JOIN booktags AS bt ON b.id= bt.bookid"; 
 			$query .= " JOIN bookcategories AS bc ON bc.id = bt.tag WHERE bc.name=?";
-- 
GitLab