Call to undefined method mysqli_stmt::get_result

Call to undefined method mysqli_stmt::get_result

  1. Blog
  2. 15 November 2026
  3. 4 min read

Stefan Bogdanescu

Founder & Senior Architect

Call to undefined method mysqli_stmt::get_result

The error Call to undefined method mysqli_stmt::get_result() is a classic symptom of a version mismatch between your PHP runtime and the MySQLi extension you are using. It appears frequently when developers upgrade their PHP environment but fail to realize that specific methods were added in later versions, or when mixing different PHP distributions (e.g., switching from standard Apache builds to Nginx/FPM builds) where extensions might be compiled differently.

In your specific case, the method get_result() was introduced in MySQLi version 5.3.6. If you are running an older version of PHP (anything below 5.3.7 or an unpatched 5.3.6), this method simply does not exist on the mysqli_stmt object, resulting in the fatal error you are seeing.

However, there is a second, equally critical issue hidden in your code logic that prevents your query from ever executing successfully, regardless of your PHP version. You noted that running the query directly in your IDE works fine, but calling it via your script fails with "Statement NOT prepared." This suggests a binding parameter error or a SQL syntax issue that is masking the actual execution failure.

Version Compatibility and Method Availability

Before debugging your application logic, you must verify your PHP version. The get_result() method is part of the newer MySQLi API improvements. If you are on an older system, switching to the procedural style of MySQLi or using PDO might be necessary as a temporary workaround, though upgrading the PHP runtime is always the preferred long-term solution.

Check your version with:

php -v

If you are below 5.3.7, you need to upgrade. If you are on a newer version but still seeing this error, ensure that your mysqli extension is actually loaded and matches the PHP binary path. Sometimes in shared hosting environments, the CLI version differs from the web server version.

The Real Culprit: Parameter Binding Issues

The fact that your script prints "Statement NOT prepared" (or rather, indicates the statement object isn't ready for fetching) points strongly to a failure during execute(). Your code snippet shows this line:

$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);

The string 'sss' tells MySQLi that all three parameters are strings. While $_POST values are technically strings, the way you are binding them might be causing a silent failure or an exception that isn't being caught, leaving $stmt in an invalid state. More importantly, if execute() throws an exception (which it does on error by default), your script stops immediately unless you have explicit error handling.

If execute() fails, the statement is not in a "ready to fetch results" state. Calling get_result() afterwards on a failed statement often triggers this specific error because the internal result pointer was never initialized.

Debugging Execution Errors

To resolve this, you must enable MySQLi error reporting and check for exceptions explicitly. Modify your execution block to handle potential errors:

$stmt->execute();
if ($stmt->error) {
    echo "Execute Error: " . $stmt->error;
} else {
    // Only call get_result here if execute was successful
    $result = $stmt->get_result();
    
    // Fetch your data
    while($row = $result->fetch_assoc()) {
        // Process row
    }
}

If you are running this on a version older than 5.3.7, get_result() will never work regardless of the execute status. In that scenario, you should use $stmt->store_result() (available in older versions) or switch to the procedural interface:

$result = $conn->mysqli->query($result_sql); // Only if using raw queries
// Or for prepared statements without get_result():
$stmt->bind_result($verified, $blocked);
$stmt->fetch();

Security and Architecture Note

Your SQL query uses Password as a column name:

SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?

Using backticks around column names that conflict with reserved words is correct practice. However, the way you are validating users based on the plain password hash stored in the database (Password) is a significant security anti-pattern. You should never compare user input directly against a stored password hash for authentication logic in modern applications; this relies on the client sending the exact hash or relying on outdated hashing algorithms.

For robust application architecture, consider migrating to PDO if you are not already using it. PDO abstracts away these version-specific discrepancies between MySQLi and other databases like PostgreSQL or SQLite, and it handles prepared statements more consistently across PHP versions.

Final Verification

If you have upgraded your PHP version to 5.3.7 or higher and added proper error handling to catch exceptions from execute(), the issue should resolve itself. If the problem persists, inspect the server logs (e.g., /var/log/php-fpm/error.log or Apache error.log) for the specific SQLSTATE code returned during the execute() phase, which will pinpoint whether the query logic itself is flawed or if it is a data integrity issue within the database.

Our network