1

I keep getting this error message and don't know why. It is a login script and I copied form here because I didn't know how to do the login using PHPASS. Here is my code:

$email      = ($_POST['email']);
$pass       = ($_POST['pass']);

require 'connect.php';
require 'PasswordHash.php';
$hash = '*';
    $login = $con->prepare("SELECT password FROM basicuserinfo WHERE email=:email");
    $login->bindParam(':email', $email);
    $login->execute();
    $login->bind_result($hash);
    if (!$login->fetch() && $con->errno)
        die();
    if ($hasher->CheckPassword($pass, $hash)) {
        $what = 'Authentication succeeded';
    } else {
        $what = 'Authentication failed';
    }
    unset($hasher);
Travis Nabbefeld
  • 393
  • 3
  • 7
  • 14
  • 3
    `bind_result` or `bindResult` do NOT exist for PDO. – hjpotter92 Mar 20 '13 at 02:33
  • `bind_result()` is a `mysqli_statement` method, not needed (or valid) for PDO. – Michael Berkowski Mar 20 '13 at 02:35
  • 2
    I wouldn't recommend copy/pasting code you don't understand. Read through it, and try to figure out what's going on, and then you might be able to debug it. – David Kiger Mar 20 '13 at 02:35
  • I read through it a bunch, and changed some, and I understand whats going on, but I didn't know what 'bind_result()' does. I know its bad practice to copy and paste code, but I just didn't know how to do this one on my own. Usually I copy and paste it, figure out whats going on and how it works, then re-write my own way. So what do I use instead of 'bind_result()' to make it work? – Travis Nabbefeld Mar 20 '13 at 02:40

1 Answers1

5

In the link that you have given, they are using MySQLi connection for MySQL related tasks. The method bind_result is one of them methods in mysqli.

This is neither needed nor necessary in method of MySQL connections. Here's a list of valid methods/constructors and classes etc. for PDO.


What you should instead use here is:

$hash = $login->fetchColumn();

where fetchColumn returns a single column from the next row of a result set.

hjpotter92
  • 78,589
  • 36
  • 144
  • 183