some error checking

This commit is contained in:
overflowerror 2014-08-16 21:02:25 +02:00
parent 7935872be3
commit 81f2624ab1

View file

@ -39,7 +39,10 @@
} }
static public function getIdByUsername ($username) { static public function getIdByUsername ($username) {
global $db; global $db;
return $db->query("SELECT `ID` FROM `users` WHERE `name`='" . $db->real_escape_string($username) . "'")->fetch_object()->ID; $result = $db->query("SELECT `ID` FROM `users` WHERE `name`='" . $db->real_escape_string($username) . "'");
if (!$result->num_rows)
throw new Exception("No entry for user " . $username);
return $result->fetch_object()->ID;
} }
static public function getRightsOnFile($uid, $file) { static public function getRightsOnFile($uid, $file) {
if ($uid == $file->userFK) if ($uid == $file->userFK)