class problem in php
<p>I am newbie to class and object.Here I have made some code for mysql database connection in class and object.in the index.php I have this code:</p>

<pre><code>&lt;?php 

  try {

    require_once('./lib/testdb.php');

    $login = new Login();

  }

  catch(Exception $error) {

    print $error-&gt;getMessage();

  }



  /* Include the HTML for the form */

  require_once('./lib/form.php');   

?&gt;
</code></pre>

<p>and for testdb.php I have this code:</p>

<pre><code>&lt;?php
  define("DB_HOST", "localhost");

  define("DB_USER", "root");

  define("DB_PASS", "root");
  class Login{
    private $username;
    private $password;
    public function getUsername() {

      return $this-&gt;username;

    }

    public function getPassword() {

      return $this-&gt;password;

    }

    public function getEncryptedPassword() {

      return sha1($this-&gt;password);

    } 

   public function connectToMySQL() {  

      @mysql_connect(DB_HOST, DB_USER, DB_PASS) OR die("Cannot connect to MySQL server!");  

      mysql_select_db("dd") OR die("Cannot select database!");

    }


    public function verifyLogin($username, $password) {

      $this-&gt;username = $username;

      if(empty($username) || empty($password)) {

        throw new Exception(Login::ERROR_EMPTY_LOGIN);

      }  

      else {

      $query = sprintf("SELECT * FROM 'users' WHERE username = '%s' AND 

            userpass = sha1('%s') ");

            $this-&gt;clean($username),

            $this-&gt;clean($password));



      $result = mysql_query($query) OR die('Cannot perform query!');  
        while($info = mysql_fetch_array( $result )) 
      {
          echo $info['username'];
      }
}
?&gt;
</code></pre>

<p>The database part is like this:</p>

<pre><code>--
-- Database: `login`
--

-- --------------------------------------------------------

--
-- Table structure for table `login`
--

CREATE TABLE IF NOT EXISTS `login` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(80) NOT NULL,
  `password` varchar(80) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

--
-- Dumping data for table `login`
--

INSERT INTO `login` (`id`, `username`, `password`) VALUES
(1, 'ajay', 'password');
</code></pre>

<p>The problem is that it is not fetching any data or nothing from the database it is showing 'Cannot perform query'.So please guide me.This one is my first project in class and object.</p>
