please bear with me as I'm just learning PDO. Anyway I keep getting the error:
Fatal error: Call to a member function prepare() on a non-object
The code is below, am I doing anything wrong? The function itself is being called out on another file as so:
$result = $database->confirmIPAddress($this->ip);
Function code:
function confirmIPAddress($value) {
    $stmt = $db->prepare("SELECT attempts, (CASE when lastlogin is not NULL and DATE_ADD(LastLogin, INTERVAL `.TIME_PERIOD.` MINUTE)>NOW() then 1 else 0 end) as Denied `.
    ` FROM `.TBL_ATTEMPTS.` WHERE ip = :ip");
    $stmt->execute(array(':ip' => $value));
    $data = $stmt->fetch(PDO::FETCH_ASSOC);
    //Verify that at least one login attempt is in database
   if (!$data) {
     return 0;
   } 
   if ($data["attempts"] >= ATTEMPTS_NUMBER)
   {
      if($data["Denied"] == 1)
      {
         return 1;
      }
     else
     {
        $this->clearLoginAttempts($value);
        return 0;
     }
   }
   return 0;  
  }
 
     
    