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()
!
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:
include 'conn.php';
$conn = new Connection();
$query = 'SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?';
$stmt = $conn->mysqli->prepare($query);
$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);
$stmt->execute();
$stmt->bind_result($EmailVerified, $Blocked);
while ($stmt->fetch())
{
/* Use $EmailVerified and $Blocked */
}
$stmt->close();
$conn->mysqli->close();
Your system is missing the mysqlnd driver!
If you are able to install new packages on your (Debian/Ubuntu-based) server, install the driver:
sudo apt-get install php5-mysqlnd
and then restart your web server:
sudo /etc/init.d/apache2 restart
for those searching for an alternative to $result = $stmt->get_result()
I've made this function which allows you to mimic the $result->fetch_assoc()
but using directly the stmt object:
function fetchAssocStatement($stmt)
{
if($stmt->num_rows>0)
{
$result = array();
$md = $stmt->result_metadata();
$params = array();
while($field = $md->fetch_field()) {
$params[] = &$result[$field->name];
}
call_user_func_array(array($stmt, 'bind_result'), $params);
if($stmt->fetch())
return $result;
}
return null;
}
as you can see it creates an array and fetches it with the row data, since it uses $stmt->fetch()
internally, you can call it just as you would call mysqli_result::fetch_assoc
(just be sure that the $stmt
object is open and result is stored):
//mysqliConnection is your mysqli connection object
if($stmt = $mysqli_connection->prepare($query))
{
$stmt->execute();
$stmt->store_result();
while($assoc_array = fetchAssocStatement($stmt))
{
//do your magic
}
$stmt->close();
}
With PHP version 7.2 I just used nd_mysqli instead of mysqli and it worked as expected.
Steps to enable it into godaddy hosting server-
I know this was already answered as to what the actual problem is, however I want to offer a simple workaround.
I wanted to use the get_results() method however I didn't have the driver, and I'm not somewhere I can get that added. So, before I called
$stmt->bind_results($var1,$var2,$var3,$var4...etc);
I created an empty array, and then just bound the results as keys in that array:
$result = array();
$stmt->bind_results($result['var1'],$result['var2'],$result['var3'],$result['var4']...etc);
so that those results could easily be passed into methods or cast to an object for further use.
Hope this helps anyone who's looking to do something similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With