简体   繁体   中英

Call to undefined method mysqli_stmt::get_result()

I am new to the php development and may be this would be the simple answer but I am having this Fatal error

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

well on my local machine, this works fine and Current PHP version is 5.6.11, and on my web server it giving this error. I have tried to chang PHP version to 5.6.30 from 5.4.45

here is my code

 $stmt = $this->conn->prepare("SELECT * FROM profile WHERE email_id = ?");
 $stmt->bind_param("s", $email);
 if ($stmt->execute()) {
     $user = $stmt->get_result()->fetch_assoc();//on this line I am having problem
     $stmt->close();
     return $user;
}

FYI: mysqlnd is enabled on my server

Why is it not working on my web server?

Please put me in right direction

Try the below code. I tailored it in relation with your problem

  $stmt = $this->conn->prepare("SELECT * FROM profile WHERE email_id = ?");
    $stmt->bind_param('s', $email);
    $result = $stmt->execute();
   $stmt->store_result();//after this line we can output the number of rows if you need to check that as well
   $number_of_rows = $stmt->num_rows;
   $meta = $stmt->result_metadata();
   $parameters = array();
  $results = array();
  while ($field = $meta->fetch_field()) {
         $parameters[] = &$row[$field->name];
  }
  call_user_func_array(array($stmt, 'bind_result'), $parameters);
       while ($stmt->fetch()) {
             foreach ($row as $key => $val) {
                  $x[$key] = $val; //here we get the key => value (Column => Value)
                      }
                      $results[] = $x; //lets grab everything here
                  }
print_r($results);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM