[php-src] Issue #8337: mysqli_stmt_bind_param Fatal error with MYSQLI_REPORT_OFF set

From: Date: Sun, 10 Apr 2022 22:40:51 +0000
Subject: [php-src] Issue #8337: mysqli_stmt_bind_param Fatal error with MYSQLI_REPORT_OFF set
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240828@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8337 Author: Madpeterz ### Description The following code: ```php <?php mysqli_report(MYSQLI_REPORT_OFF); $mysqli_report = mysqli_init(); mysqli_real_connect($mysqli_report, "localhost", "example", "example", "example"); try { $sql = "SELECT * FROM example WHERE cvalue = ? OR cvalue = ?"; $stmt = $mysqli_report->prepare($sql); if ($stmt === false) { $error_msg = "unable to prepair: " . $mysqli_report->error; die($error_msg); } $bind_text = "ii"; $bind_args = [13]; $result = mysqli_stmt_bind_param($stmt, $bind_text, ...$bind_args); die("This should not run: ".json_encode($result)); } catch (Exception $e) { error_log("in error log: " . $e->getMessage()); } ``` Resulted in this output: ``` PHP Fatal error: Uncaught ArgumentCountError: The number of elements in the type definition string must match the number of bind variables in mysqli.php:16 Stack trace: #0 mysqli.php(16): mysqli_stmt_bind_param(Object(mysqli_stmt), 'ii', 13) #1 {main} thrown in mysqli.php on line 16 Fatal error: Uncaught ArgumentCountError: The number of elements in the type definition string must match the number of bind variables in mysqli.php:16 Stack trace: #0 mysqli.php(16): mysqli_stmt_bind_param(Object(mysqli_stmt), 'ii', 13) #1 {main} thrown in mysqli.php on line 16 ``` But I expected this output instead: ``` in error log: The number of elements in the type definition string must match the number of bind variables ``` ### PHP Version PHP 8.1.4 (cli) (built: Mar 16 2022 09:33:31) ### Operating System Windows 11

« previous php.bugs (#240828) next »