Fatal Error: Call to Undefined Method MySQLi_Stmt::Get_Result()

Call to undefined method mysqli_stmt::get_result

Please read the user notes for this method:

http://php.net/manual/en/mysqli-stmt.get-result.php

It requires the mysqlnd driver... If it isn't installed on your webspace you will have to work with bind_result() & fetch()!

Call to undefined method mysqli_stmt::get_results()

This was the solution code my friend helped me solve :) Just incase anyone experienced the same issue...


session_start();

if (isset($_POST['submit'])) {

include 'dbh.inc.php';

$uid = $_POST['uid'];
$pwd = $_POST['pwd'];

# Error handlers
# Check if inputs are empty
if (empty($uid) || empty($pwd)) {
header("Location: ../index.php?login=empty");
exit();
} else {
$sql = "SELECT * FROM users WHERE user_uid= ?";
$stmt = $conn->prepare($sql);
$stmt->bind_param("s", $_POST['uid']);
$stmt->execute();
$result = $stmt->get_result();
$num_rows = $result->num_rows;

if($num_rows == 1) {

while ($rows = $result->fetch_assoc()) {
if (!password_verify($pwd, $rows['user_pwd'])) {
header("Location: ../index.php?login=errorchecker");
exit();
} else {
#Logs in
$_SESSION['u_id'] = $rows['user_id'];
$_SESSION['u_first'] = $rows['user_first'];
$_SESSION['u_last'] = $rows['user_last'];
$_SESSION['u_email'] = $rows['user_email'];
$_SESSION['u_uid'] = $rows['user_uid'];
header("Location: ../index.php?login=success");
exit();
}
}

$read->close();
} else {
header("Location: ../index.php?login=errorb4pwcheck");
}
}

}

Fatal error: Call to undefined method mysqli_stmt::get_result()

This is too long for a comment.

Try this:

if($statement=$conn->prepare("SELECT * FROM users WHERE token= ? LIMIT 1")){

$statement-> bind_param('s',$cvalue);

// Execute
$statement-> execute();

// Bind results
$statement-> bind_result($token);

// Fetch value
while ( $statement-> fetch() ) {
echo $token . "<br>";
}

// Close statement
$statement-> close();
}

// Close entire connection
$conn-> close();

Now, if while ( $statement-> fetch() ) doesn't work quite like you want it to, try replacing it with while ( $statement-> fetch_assoc() ), the way you have it now.

  • N.B.: If this doesn't work for you, I will simply delete the answer.

Footnotes:

As Rocket Hazmat stated in a comment, and I quote: It requires both PHP 5.3+ and the mysqlnd driver.

So, make sure that the driver is installed.

  • http://php.net/manual/en/book.mysqlnd.php
  • http://php.net/manual/en/mysqlnd.install.php

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()

I heard back from my hosting support and they confirmed that unchecking mysqli and checking nd_mysqli (Optional: unchecking pdo_mysql and checking nd_pdo_mysql) is the right way to go.

Sample Image
Sample Image

and it works correctly!

Uncaught Error: Call to undefined method mysqli_stmt::get_result() in

bind result

So if the MySQL Native Driver (mysqlnd) driver is not available, and therefore using bind_result and fetch instead of get_result, the code becomes:

if ($stmt = $mysqli->prepare("SELECT col1,col2 FROM table_users WHERE email = ?")) {
$stmt->bind_param("s", $email);
$stmt->execute();

/* bind variables to prepared statement */
$stmt->bind_result($col1, $col2);

/* fetch values */
while ($stmt->fetch()) {
printf("%s %s\n", $col1, $col2);
}

/* close statement */
$stmt->close();
}

Call to undefined method mysqli_stmt::get_result() AND mysqlnd installed

For anybody wondering what's going on with this, and using Arvixe. Here is the response I received from the staff.

This is some confusion around MySQLND which was caused by an old
platform and its something I'll be communicating to my staff.

We used to run a system which allowed us to have individual PHP
installs and at that point 5.4 and 5.5 both had MysqlND running. The
new PHP system we have in place runs all PHP installs on a consistent
config and therefore with our PHP 5.3 install (the base install) not
using MySQLND nor does our 5.4 or 5.5 install.

This will be reviewed in future as PHP 5.6 is going to have MySQLND as
a default.

Currently the only way we can support MySQLND is via a VPS / dedicated
server.

So, if you're on Arvixe and not a VPS, you're out of luck for using a super common and recommended convention for retrieving data from your database. There are workarounds for this using a ton of different methods. They either aren't feasible for my project or I couldn't get them to work, but for smaller queries it seems that using $stmt->bind_result() is one of the more popular methods.
http://php.net/manual/en/mysqli-stmt.bind-result.php

For me, I'm taking my business back to GoDaddy. I spent over 10 hours trying to get a solution for this with no resolution offered except "We have a 60 day money back guarantee if you're not satisfied."

Thanks everyone for helping out with this. Frustrating as it's been, I learned a lot in the process and from these boards... As is usually the case.

Uncaught Error: Call to undefined method mysqli_stmt::fetchAll()

This is because there is no such function! You are mixing PDO and mysqli.

If you want to fetch all records from a mysqli prepared statement you need to do it in two steps. First, fetch the result set using mysqli_stmt::get_result() and then use mysqli_result::fetch_all()

$query = "Select * from tblorders";
$stmt = $connection->prepare($query);
$stmt->execute();

$resultSet = $stmt->get_result();
$data = $resultSet->fetch_all(MYSQLI_ASSOC);

However, I would strongly advise learning PDO instead of mysqli as it is much easier and offers more options.



Related Topics



Leave a reply



Submit