Check query return value in search_results_page()

Instead of unconditionally calling fetch on the return value of query(),
error out early if the value evaluates to false. Also, make sure that
the results array is always initialized, even if the result set is
empty.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2017-04-18 08:36:29 +02:00
parent 5553d01ab3
commit 6090c2ae8b

View file

@ -495,9 +495,12 @@ function search_results_page($O=0,$SB="",$U="",$T="",
$result = $dbh->query($q); $result = $dbh->query($q);
$userinfo = array();
if ($result) {
while ($row = $result->fetch(PDO::FETCH_ASSOC)) { while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
$userinfo[] = $row; $userinfo[] = $row;
} }
}
include("account_search_results.php"); include("account_search_results.php");
return; return;