Viewed   444 times

I keep getting the error PHP Fatal error: Call to undefined function mysqli_stmt_get_result(). I am using PHP version 5.6 and have enabled the extension mysqlind in my hosting provider c panel but I can't figure out why I am still getting this error. I have researched and found every time that I need to have mysqli nd enabled to use mysqli_stmt_get_result. Can anyone assist/teach what I am doing wrong. Thank you.


    include '../dbh.php';

    $respond = array(
        'status' => true,
        'message' => 'There was an error',

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

        $first = $_POST['first'];
        $last  = $_POST['last'];
        $email = $_POST['email'];
        $pwd   = $_POST['pwd'];

        $errorEmpty = false;
        $errorEmail = false;

        if (empty($first) || empty($last) || empty($email) || empty($pwd)) {

            $respond['errors'][]   = "Please fill out all fields!";
            $respond['errorEmpty'] = true;

        } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
            $respond['errors'][]   = "Please enter a valid email address!";
            $respond['errorEmail'] = true;

        } else {
            $sql  = "SELECT email FROM user WHERE email= ? ";
            $stmt = mysqli_prepare($conn, $sql);
            mysqli_stmt_bind_param($stmt, 's', $email);
            $result   = mysqli_stmt_get_result($stmt);  //This is where I getting my error
            $num_rows = mysqli_num_rows($result);
            if ($num_rows > 0) {
                $respond['errors'][]   = "That email address already exists!";
                $respond['errorEmail'] = true;

            else {
                $encryptpwd = password_hash($pwd, PASSWORD_DEFAULT);
                $sql        = "INSERT INTO user (first, last, email, pwd) VALUES (?,?,?,?)";
                $stmt       = mysqli_prepare($conn, $sql);
                mysqli_stmt_bind_param($stmt, 'ssss', $first, $last, $email, $password_hash);

                if (mysqli_stmt_execute($stmt)) {

                    $userID = mysqli_insert_id($conn);
                    $status = 1;
                    $sql2   = "INSERT INTO profileImg (email, status) VALUES(?,?)";
                    $stmt2  = mysqli_prepare($conn, $sql2);
                    mysqli_stmt_bind_param($stmt2, 'si', $email);

                    $_SESSION['id'] = $userID;

                    $respond['redirect'] = "../profile.php?id=$userID";
    echo json_encode($respond);



Do you have the mysqlnd driver properly installed? Per a comment in the Manual:

If you don't have mysqlnd installed/loaded whatever, you will get an undefined reference when trying to call "mysqli_stmt_get_result()".

Also, there are discussions about this issue here and here.

Lastly, here's a forum discussing info pertaining to using the driver with cpanel that you may find useful.

Thursday, December 15, 2022

No. Fatal errors are fatal. Even if you were to write your own error handler or use the @ error suppression operator, E_FATAL errors will still cause the script to halt execution.

The only way to handle this is to use function_exists() (and possibly is_callable() for good measure) as in your example above.

It's always a better idea to code defensively around a potential (probable?) error than it is to just let the error happen and deal with it later anyway.

EDIT - php7 has changed this behavior, and undefined functions/methods are catchable exceptions.

Wednesday, November 2, 2022

I would say just build it yourself. You can set it up like this:

$query = "INSERT INTO x (a,b,c) VALUES ";
foreach ($arr as $item) {
  $query .= "('".$item[0]."','".$item[1]."','".$item[2]."'),";
$query = rtrim($query,",");//remove the extra comma
//execute query

Don't forget to escape quotes if it's necessary.

Also, be careful that there's not too much data being sent at once. You may have to execute it in chunks instead of all at once.

Saturday, November 5, 2022

It happens because you are declaring the function after trying to call it:

tally($_POST[$qvar]);// LINE THAT CAUSES ERROR

function tally ($question) // TALLY FUNCTION DECLARATION COMES LATER

I would put either before if(isset($_POST['submit'])) { or as the first thing inside.

   if (!function_exists('tally')) {
   function tally ($question) // TALLY FUNCTION
            global $nowval;

$this->tally won't work because it's not an Object, you are justing decrating a function.

Sunday, November 6, 2022

The function you're looking for is find_in_set:

 select * from ... where find_in_set($word, pets)

for multi-word queries you'll need to test each word and AND (or OR) the tests:

  where find_in_set($word1, pets) AND find_in_set($word2, pets) etc 
Wednesday, August 17, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :