From af09b01f5945fa9c47e0d0cb5eea47fcb58fa8aa Mon Sep 17 00:00:00 2001 From: Stefan Brannfjell Date: Sat, 31 Aug 2013 13:38:40 +0200 Subject: [PATCH] fixed warning if text is false. --- forum_search.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/forum_search.php b/forum_search.php index bc36582..220462e 100644 --- a/forum_search.php +++ b/forum_search.php @@ -16,24 +16,25 @@ $type = getValue($_GET['type']); if ($type !== false) $type = (int)$type; $text = getvalue($_GET['text']); -$text = explode(' ', $text); $textTitleSql = ""; $textPostSql = ""; $textAuthorSql = ""; -for ($i = 0; $i < count($text); $i++) { - if ($i != count($text) -1) { - $textTitleSql .= "`title` LIKE '%". $text[$i] ."%' AND "; - $textPostSql .= "`text` LIKE '%". $text[$i] ."%' AND "; - $textAuthorSql .= "`player_name` LIKE '%". $text[$i] ."%' AND "; - } else { - $textTitleSql .= "`title` LIKE '%". $text[$i] ."%'"; - $textPostSql .= "`text` LIKE '%". $text[$i] ."%'"; - $textAuthorSql .= "`player_name` LIKE '%". $text[$i] ."%'"; +if ($text !== false) { + $text = explode(' ', $text); + for ($i = 0; $i < count($text); $i++) { + if ($i != count($text) -1) { + $textTitleSql .= "`title` LIKE '%". $text[$i] ."%' AND "; + $textPostSql .= "`text` LIKE '%". $text[$i] ."%' AND "; + $textAuthorSql .= "`player_name` LIKE '%". $text[$i] ."%' AND "; + } else { + $textTitleSql .= "`title` LIKE '%". $text[$i] ."%'"; + $textPostSql .= "`text` LIKE '%". $text[$i] ."%'"; + $textAuthorSql .= "`player_name` LIKE '%". $text[$i] ."%'"; + } } + //data_dump($text, array($textTitleSql, $textPostSql, $textAuthorSql), "search"); } -data_dump($text, array($textTitleSql, $textPostSql, $textAuthorSql), "search"); - ?>

Search forum

@@ -204,4 +205,5 @@ if ($type !== false && $text !== false && $type <= 4 || $type > 4 && $type <= 6) } else echo "No results."; } else echo "
You must fill in all fields!"; -include 'layout/overall/footer.php'; ?> \ No newline at end of file +include 'layout/overall/footer.php'; +?> \ No newline at end of file