. Advertisement .
..3..
. Advertisement .
..4..
I get an error:
Call to undefined method mysqli_stmt::get_result()
when I try to run the following code:
include 'conn.php';
$conn = new Connection();
$query = 'SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?';
$stmt = $conn->mysqli->prepare($query);
$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);
$stmt->execute();
$result = $stmt->get_result();
define('SERVER', 'localhost');
define('USER', 'root');
define('PASS', 'xxxx');
define('DB', 'xxxx');
class Connection{
/**
* @var Resource
*/
var $mysqli = null;
function __construct(){
try{
if(!$this->mysqli){
$this->mysqli = new MySQLi(SERVER, USER, PASS, DB);
if(!$this->mysqli)
throw new Exception('Could not create connection using MySQLi', 'NO_CONNECTION');
}
}
catch(Exception $ex){
echo "ERROR: ".$e->getMessage();
}
}
}
if(!stmt) echo 'Statement prepared'; else echo 'Statement NOT prepared';
How to fix the call to undefined method mysqli_stmt::get_result(). Please give me some good ideas.
The cause:
After examining your problem, I found that you did not install the mysqlnd drive for your system, so it caused the error ”call to undefined method mysqli_stmt::get_result()”.
Solution:
If you are not able to install the mysqlnd drive, you can use
bind_result()
&fetch()
to replace it.You can refer some notes of this solution which users have already listed:
http://php.net/manual/en/mysqli-stmt.get-result.php
Another way is installing the driver if you can set up new packages on your server (for example, base on Debian or Ubuntu).
Let’s use this command to restart your server:
If the MySQL Native Driver (mysqlnd), driver is unavailable, then bind_result or fetch are used instead of get_result. The code will become: