4

Initially I had this error saying Call to undefined method mysqli_stmt::get_result() Then after searching I found out that I have to enable mysqlnd driver for that. I using godaddy hosting site and I have enabled the mysqlnd driver but I am still facing the same issue.enter image description here I have many function with get_result so solving each and one of em with bind_result is gonna be very time consuming and hectic for me. How can I fix this issue Let's say I have this query

$stmt = $this->conn->prepare("SELECT * FROM registeration_table WHERE phone = ?");
            $stmt->bind_param("s", $phone);
            $stmt->execute();
            $user = $stmt->get_result()->fetch_assoc();
            $stmt->close();
            return $user;

To resolve this error I have gone throught his link Stackoverflow link And implement this function

    public function get_result($Statement) {
    $RESULT = array();
    $Statement->store_result();
    for ( $i = 0; $i < $Statement->num_rows; $i++ ) {
        $Metadata = $Statement->result_metadata();
        $PARAMS = array();
        while ( $Field = $Metadata->fetch_field() ) {
            $PARAMS[] = &$RESULT[ $i ][ $Field->name ];
        }
        call_user_func_array( array( $Statement, 'bind_result' ), $PARAMS );
        $Statement->fetch();
    }
    return $RESULT;
}

Thank you.

Community
  • 1
  • 1
  • have you restarted the server? – Sepultura Mar 08 '17 at 09:15
  • They said restarting the hosting server is not an option. But after reloading the page i can see that mysqlnd is checked –  Mar 08 '17 at 10:41
  • add `phpinfo()` function and check by yourselft on your page that extension in enabled or not – jamek Mar 08 '17 at 11:54
  • @jamek yea i have checked it's enabled –  Mar 08 '17 at 12:12
  • I meant restarting the apache server, if you have ssh access to the server this shouldn't be a problem – Sepultura Mar 08 '17 at 12:33
  • sorry let me try –  Mar 08 '17 at 12:35
  • @Sepultura they said since it's hosting we can not restart the apache server the alternative was to kill all the php process and it will restart again. I tried but still getting the same error –  Mar 09 '17 at 05:37
  • well that's strange, do you have ssh access to the server? if yes, just restart it with this command: `sudo service apache2 restart`, I don't see any reason why this shouldn't be possible – Sepultura Mar 09 '17 at 08:55
  • I'm having this exact same issue and it's driving me crazy. I have also verified that both `mysqli` and `mysqlnd` are enabled and running with `phpinfo` – vane Aug 05 '17 at 01:28
  • any solution for this..? having same issue :/ – TejpalBh Jun 27 '19 at 06:16

0 Answers0