0
public function getUserByEmailAndPassword($email, $password) {

    $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");

    $stmt->bind_param("s", $email);

    if ($stmt->execute()) {
        $user = $stmt->bind_result($name,$email);
        while($user->fetch_assoc())
        {
        echo $name. "<br>" .$email;
        }
        $stmt->close();

        // verifying user password
        $salt = $user['salt'];
        $encrypted_password = $user['encrypted_password'];
        $hash = $this->checkhashSSHA($salt, $password);
        // check for password equality
        if ($encrypted_password == $hash) {
            // user authentication details are correct
            return $user;
        }
    } else {
        return NULL;
    }
}

Error:- Value br of type java.lang.String cannot be converted to JSONObject in Error screenshot Android Please help me to find out this error Thank you in advance.

enter image description here

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98
Abhishek Kumar
  • 747
  • 1
  • 5
  • 13
  • try : boolean error = Boolean.parseBoolean(jObj.getString("error")); – M.Waqas Pervez Jun 21 '16 at 06:21
  • Why do you use bind_result and not get_result? And in the error you can see that the params in bind_result does not match the numbers of fields in your Users table. What's in your Users table? – M4R1KU Jun 21 '16 at 06:25
  • in user tables I have id unique id name password email created at and updated at! – Abhishek Kumar Jun 21 '16 at 06:29
  • and also I have one entry with name mail and password, error is coming while I am login through device – Abhishek Kumar Jun 21 '16 at 06:32
  • so try to make the following: `$stmt->bind_result($id, $name, $pw, $email, $created, $updated)` that should work as far as I know, you can also read this [question](http://stackoverflow.com/questions/18753262/example-of-how-to-use-bind-result-vs-get-result) – M4R1KU Jun 21 '16 at 06:32

1 Answers1

0

Problem : The bind_result warning caused by the number of column resulted by your query doesnt match the parameter you give in bind_result($name,$email) (only 2 param) and i think your query result give greater than 2 column.

Solution : you must know how much column resulted by your sql SELECT * and then, add param to the bind_result() exactly the same as the number of column resulted.

And use mysqli_fetch_assoc() instead of fetch_assoc().

arisalsaila
  • 429
  • 2
  • 7