PHP 8.5: mysqli_execute alias function deprecated in favor of mysqli_stmt_execute

Version8.5
TypeDeprecation

The mysqli_execute function from the mysqli extension is an alias to the mysqli_stmt_execute function.

The function name mysqli_execute is confusing, because it works on mysqli_stmt objects rather than mysqli objects that other mysqli_* functions accept or return.

In PHP 8.5, the alias mysqli_execute function is deprecated in favor of the more aptly named mysqli_stmt_execute function.


Attempting to use the mysqli_execute function emits a deprecation notice:

mysqli_execute($stmt);
Function mysqli_execute() is deprecated since 8.5, use mysqli_stmt_execute() instead

Recommended Replacement

Because the mysqli_execute function is an alias to the mysqli_stmt_execute function, replacing all mysqli_execute calls with mysqli_stmt_execute is a backward-compatible replacement with identical functionality.

- mysqli_execute($stmt);
+ mysqli_stmt_execute($stmt);

Alternately, the mysqli_execute_query function added in PHP 8.2 can be used directly execute a query from a mysqli object.

  $query = 'SELECT uid, username FROM users WHERE uid = ?';
- $statement = mysqli_prepare($connection, $query);
- mysqli_execute($statement);
- $result = mysqli_stmt_get_result($statement);
+ $result = mysqli_execute_query($connection, $query, $uid);

mysqli_execute mysqli_stmt_execute RFC Implementation