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

From: Date: Thu, 15 Jul 2021 19:00:13 +0000
Subject: Bug #81262 [NEW]: 0 parameters in mysqli_prepare statement
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-235066@lists.php.net to get a copy of this message
From: bigarn13 at gmail dot com Operating system: Windows 8 PHP version: 8.0.8 Package: MySQLi related Bug Type: Bug Bug description:0 parameters in mysqli_prepare statement 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 bug report at https://bugs.php.net/bug.php?id=81262&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=81262&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=81262&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=81262&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=81262&r=needscript Try newer version: https://bugs.php.net/fix.php?id=81262&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=81262&r=support Expected behavior: https://bugs.php.net/fix.php?id=81262&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=81262&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=81262&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=81262&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=81262&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=81262&r=dst IIS Stability: https://bugs.php.net/fix.php?id=81262&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=81262&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=81262&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=81262&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=81262&r=mysqlcfg

« previous php.bugs (#235066) next »