N
N
Nick20152016-01-11 16:57:46
PHP
Nick2015, 2016-01-11 16:57:46

mysqli_stmt::get_result?

When I send a Post request for registration (authorization) using the Advanced REST client, I get an error

Call to undefined method mysqli_stmt::get_result() in <b>/home/u121618341/public_html/api/v2/include/DB_Functions.php</b> on line <b>64

Line 64
$user = $stmt->get_result()->fetch_assoc();
Here is the entire DB_Functions
<?php

/**
 * @author Ravi Tamada
 * @link http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ Complete tutorial
 */

class DB_Functions {

    private $conn;

    // constructor
    function __construct() {
        require_once 'DB_Connect.php';
        // connecting to database
        $db = new Db_Connect();
        $this->conn = $db->connect();
    }

    // destructor
    function __destruct() {
        
    }

    /**
     * Storing new user
     * returns user details
     */
    public function storeUser($name, $email, $password) {
        $uuid = uniqid('', true);
        $hash = $this->hashSSHA($password);
        $encrypted_password = $hash["encrypted"]; // encrypted password
        $salt = $hash["salt"]; // salt

        $stmt = $this->conn->prepare("INSERT INTO users(unique_id, name, email, encrypted_password, salt, created_at) VALUES(?, ?, ?, ?, ?, NOW())");
        $stmt->bind_param("sssss", $uuid, $name, $email, $encrypted_password, $salt);
        $result = $stmt->execute();
        $stmt->close();

        // check for successful store
        if ($result) {
            $stmt = $this->conn->prepare("SELECT * FROM users WHERE email = ?");
            $stmt->bind_param("s", $email);
            $stmt->execute();
            $user = $stmt->get_result()->fetch_assoc();
            $stmt->close();

            return $user;
        } else {
            return false;
        }
    }

    /**
     * Get user by email and password
     */
    public function getUserByEmailAndPassword($email, $password) {

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

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

        if ($stmt->execute()) {
            $user = $stmt->get_result()->fetch_assoc();
            $stmt->close();
            return $user;
        } else {
            return NULL;
        }
    }

    /**
     * Check user is existed or not
     */
    public function isUserExisted($email) {
        $stmt = $this->conn->prepare("SELECT email from users WHERE email = ?");

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

        $stmt->execute();

        $stmt->store_result();

        if ($stmt->num_rows > 0) {
            // user existed 
            $stmt->close();
            return true;
        } else {
            // user not existed
            $stmt->close();
            return false;
        }
    }

    /**
     * Encrypting password
     * @param password
     * returns salt and encrypted password
     */
    public function hashSSHA($password) {

        $salt = sha1(rand());
        $salt = substr($salt, 0, 10);
        $encrypted = base64_encode(sha1($password . $salt, true) . $salt);
        $hash = array("salt" => $salt, "encrypted" => $encrypted);
        return $hash;
    }

    /**
     * Decrypting password
     * @param salt, password
     * returns hash string
     */
    public function checkhashSSHA($salt, $password) {

        $hash = base64_encode(sha1($password . $salt, true) . $salt);

        return $hash;
    }

}

?>

When you log in there is an error and 0 effect, and when you log in, the same error is only in line 45 (similar to 64), but the data is entered into the database. Hosting database (hostinger.com).
a80a36f05d9d404aba645b61bd8e3c06.jpg
Here are the php settings on the server and on the LAN WHERE EVERYTHING WORKS OK.
How to solve this problem.
mysqlnd - installed on the hosting.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Karnaukhov, 2016-01-11
@BupycNet

Have you read this? stackoverflow.com/questions/8321096/call-to-undefi...
What PHP version?
"Note: mysqli_stmt::get_result() is only available at PHP v5.3.0 or above."

X
xmoonlight, 2016-01-16
@xmoonlight

API extensions on the server is empty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question