Bug #81262 [Fbk->NoF]: 0 parameters in mysqli_prepare statement
| From: | php-bugs at lists dot php dot net | Date: | Sun, 25 Jul 2021 04:22:13 +0000 |
| Subject: | Bug #81262 [Fbk->NoF]: 0 parameters in mysqli_prepare statement | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235326@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
Updated by: php-bugs@lists.php.net
Reported by: bigarn13 at gmail dot com
Summary: 0 parameters in mysqli_prepare statement
-Status: Feedback
+Status: No Feedback
Type: Bug
Package: MySQLi related
Operating System: Windows 8
PHP Version: 8.0.8
Assigned To: cmb
Private report: N
New Comment:
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
Previous Comments:
------------------------------------------------------------------------
[2021-07-15 19:25:54] dharman@php.net
Please also let us know if you are using mysqlnd or some version of libmysqlclient and if so which
one?
------------------------------------------------------------------------
[2021-07-15 19:20:51] dharman@php.net
What is $members? Can you show the compiled SQL?
While Patrick is somewhat right that there is no need to use prepare and execute for static queries,
there is also absolutely nothing wrong with using them without placeholders.
If there is a bug then we would like to be able to reproduce it. Can you please provide the full SQL
to reproduce the problem?
------------------------------------------------------------------------
[2021-07-15 19:14:34] patrickallaert@php.net
There is no reasons to use "prepare" then "execute" for queries without
parameters. Use mysqli_query() directly.
------------------------------------------------------------------------
[2021-07-15 19:05:40] bigarn13 at gmail dot com
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
------------------------------------------------------------------------
[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