|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patches0_parameters_in_mysqli_prepare_stmt (last revision 2021-07-15 19:05 UTC by bigarn13 at gmail dot com)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-07-15 19:05 UTC] bigarn13 at gmail dot com
[2021-07-15 19:14 UTC] patrickallaert@php.net
[2021-07-15 19:20 UTC] dharman@php.net
[2021-07-15 19:25 UTC] dharman@php.net
[2021-07-16 11:45 UTC] cmb@php.net
-Status: Open
+Status: Feedback
-Assigned To:
+Assigned To: cmb
[2021-07-25 04:22 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 15:00:01 2025 UTC |
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