title: Call to a member function bindParam() on a non-object
body: <p>I'm working a log-in script that I found on the web. (<a href="http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/" rel="nofollow">http://alias.io/2010/01/store-passwords-safely-with-php-and-mysql/</a>)</p>
  
  <p>As I was trying to make it work, I stumbled upon this error:</p>
  
  <p>bool(false)
  Fatal error: Call to a member function bindParam() on a non-object in /srv/disk3/1446018/www/askmephilosophy.co.nf/session.php on line 25</p>
  
  <p>My code:</p>
  
  <pre><code>&lt;?php
  
    include('config.php');
  
    //  Establishing the connection:
    $MyConnection = mysqli_connect('hostname', 'user', 'pass', 'database')
      or die('An error has occured when you were trying to login. You can return to the main page
        by clicking: &lt;a href="index.php"&gt;here&lt;/a&gt;. &lt;br /&gt;
        If this error is consistent, please &lt;a href="contact.php"&gt;contact us&lt;/a&gt;.');
  
    //  Information provide by the user:
    $username = $_POST['username'];
    $password = $_POST['password']; // Text version.
  
    $StatementHandle = $MyConnection-&gt;prepare('
      SELECT
        hash
      FROM Users
      WHERE
        username = :username
      LIMIT 1
      ');
  
    var_dump($StatementHandle);
    $StatementHandle-&gt;bindParam(':username', $username);
  
    $StatementHandle-&gt;execute();
  
    $user = $StatementHandle-&gt;fetch(PDO::FETCH_OBJ);
  
    // Hashing the password with its hash as the salt returns the same hash:
    if(crypt($password, $user-&gt;hash) == $user-&gt;hash) {
      echo 'You are logged in. Well, not actually. We only just confirmed that
        our system works. This service\'ll cost you $1';
    }
  
  ?&gt;
  </code></pre>