test return value from db_query before assuming it is valid

make the sql query form consistent in usage by cleaning up instances
where db_query's result was not inspected before attempting to fetch row
data from the handle

Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
elij 2011-05-11 16:17:12 -07:00 committed by Lukas Fleischer
parent d38f3460e5
commit 0898f1447a
7 changed files with 135 additions and 68 deletions

View file

@ -491,8 +491,12 @@ function get_salt($user_id)
{
$dbh = db_connect();
$salt_q = "SELECT Salt FROM Users WHERE ID = " . $user_id;
$salt_result = mysql_fetch_row(db_query($salt_q, $dbh));
return $salt_result[0];
$result = db_query($salt_q, $dbh);
if ($result) {
$salt_row = mysql_fetch_row($result);
return $salt_row[0];
}
return;
}
function save_salt($user_id, $passwd)