Bug #81262 [PATCH]: 0 parameters in mysqli_prepare statement

From: Date: Thu, 15 Jul 2021 19:05:40 +0000
Subject: Bug #81262 [PATCH]: 0 parameters in mysqli_prepare statement
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235067@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81262&edit=1 ID: 81262 Patch added by: bigarn13@gmail.com Reported by: bigarn13 at gmail dot com Summary: 0 parameters in mysqli_prepare statement Status: Open Type: Bug Package: MySQLi related Operating System: Windows 8 PHP Version: 8.0.8 Block user comment: N Private report: N New Comment: The following patch has been added/updated: Patch Name: 0_parameters_in_mysqli_prepare_stmt Revision: 1626375940 URL: https://bugs.php.net/patch-display.php?bug=81262&patch=0_parameters_in_mysqli_prepare_stmt&revision=1626375940 Previous Comments: ------------------------------------------------------------------------ [2021-07-15 19:00:13] bigarn13 at gmail dot com Description: ------------ I want to execute a query that has no parameters. To be consistent, I would like to prepare this query as I do all other queries. In the Test script below, $stmt = ... executes ok. When the mysqli_stmt_bind_param(...) is executed the interpreter complains: Fatal error: Uncaught ValueError: mysqli_stmt_bind_param(): Argument #2 ($types) cannot be empty... The manual page for mysqli_prepare states that 0 or more place holder ? can appear in the SQL, at the top level (no quotes), only in places where values are expected, etc... My SELECT statement complies with all that. So I tried deleting the mysqli_stmt_bind_param(...) line, because there are no parameters to bind. In this case, the interpreter complains when the mysqli_stmt_execute($stmt); is executed that no parameters have been bound! But there are no parameters in this SELECT query. No changes were made tp php.ini It looks like a core issue to me. My version of php is reported as PHP version: 8.0.5, so I chose the closest match 8.08 ? Test script: --------------- $stmt = mysqli_prepare($con, "SELECT _id, _user_id, _email FROM $members WHERE _user_id IS NULL"); mysqli_stmt_bind_param($stmt, ""); mysqli_stmt_execute($stmt); Expected result: ---------------- Please provide a workaround or technique I can use now to prepare a query with 0 parameters. Actual result: -------------- Stack trace: #0 C:\xampp\htdocs\sample.php(nnn): mysqli_stmt_bind_param(Object(mysqli_stmt), '') #1 {main} thrown in C:\xampp\htdocs\sample.php on line nnn ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81262&edit=1

« previous php.bugs (#235067) next »