我是php开发的新手,可能这将是一个简单的答案,但我有这个致命的错误
致命错误:调用未定义的方法mysqli_stmt :: get_result() 在
在我的本地机器上运行良好,当前的PHP版本是5.6.11,在我的Web服务器上它给出了这个错误。我试图从5.4.45
将PHP版本改为5.6.30这是我的代码
$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;
}
仅供参考:我的服务器上启用了mysqlnd
为什么它不能在我的网络服务器上运行?
请把我指向正确的方向
答案 0 :(得分:1)
尝试以下代码。我根据你的问题量身定做了
$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);