title: Method not found in class
body: <p>I'm working on a login function but got an error that I can't figure out.</p>
  
  <p>This is my Model Login class:</p>
  
  <pre><code>class Login {
  
      private $username;
      private $password;
      private $cxn;       //database object
  
      function __construct($username,$password)
      {
          //set data
          $this-&gt;setData($username, $password);
          //connect DB
          $this-&gt;connectToDB();
          // get Data 
      }
  
      function setData($username, $password)
      {
          $this-&gt;username = $username;
          $this-&gt;password = $password;
      }
  
      private function connectToDB()
      {
          include 'Database.php';
          $connect = '../include/connect.php';
          $this-&gt;cxn = new database($connect);  
      }
  
      function getData()
      {
          $query = "SELECT * FROM anvandare WHERE anvandarnamn = '$this-&gt;username' AND losenord ='$this-&gt;'password'";
          $sql = mysql_query($query);
  
          if(mysql_num_rows($sql)&gt;0)
          {
              return true;
          }
          else
          {
              throw new Exception("Användarnamnet eller Lösenordet är fel. Försök igen.");
          } 
      }
  
      function close() 
      {
          $this-&gt;cxn-&gt;close(); //Here is the error it says "Method 'close' not found in class
      }
  }
  </code></pre>
  
  <p>The last function gives error "<em>Method 'close' not found in class</em>", "<em>Referenced method is not found in subject class.</em>"</p>
  
  <p>Here is my Database class:</p>
  
  <pre><code>class Database {
  
      private $host;
      private $user;
      private $password;                  
      private $database;
  
     function __construct($filename)
     {       
         if(is_file($filename)) include $filename;
         else throw new exception("Error!");
  
         $this-&gt;host=$host;
         $this-&gt;user=$user;
         $this-&gt;password=$password;
         $this-&gt;database=$database;
  
         $this-&gt;connect();
      }
  
      private function connect()
      {
          //Connect to the server
          if(!mysql_connect($this-&gt;host, $this-&gt;user, $this-&gt;password))
          throw new exception("Error, not connected to the server.");
  
          //Select the database
          if(!mysql_select_db($this-&gt;database))
          throw new exception("Error, no database selected");             
      }
  
      function close()
      {
          mysql_close();
      }
  }
  </code></pre>
  
  <p>The pathways are correct so it's not it. What could be the error? </p>