Bug #80257 [NEW]: variable in the prepared statement not refreshed when multiple call

From: Date: Mon, 19 Oct 2020 13:05:06 +0000
Subject: Bug #80257 [NEW]: variable in the prepared statement not refreshed when multiple call
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229748@lists.php.net to get a copy of this message
From:             webmaster at seobytes dot eu
Operating system: Linux/windows
PHP version:      7.3.23
Package:          MySQLi related
Bug Type:         Bug
Bug description:variable in the prepared statement not refreshed when multiple call

Description:
------------
When executing a prepared statement to UPDATE a date in some row, then
unsetting the variable and then executing the prepared statement again,
redeclaring the variable and setting a new date to UPDATE a different
ROW, the date written in the database does not change compare with the
first execution despite the variable  displaying the proper value just
ahead of execution, although execution to UPDATE a date in a loop does
not cause any issue.

 Tested on windows server and Linux server. PHP 7.2 and 7.3

Test script:
---------------
$conn = new mysqli($servername, $username, $password, $db);
$stmt=$conn->prepare("UPDATE _products SET product_available_date=?
WHERE product_sku=?");
$stmt->bind_param("ss", $product_available_date,$product_sku);
$product_available_date='2020-10-19';
$product_sku='some_value';
$stmt->execute();
unset($product_available_date);
$product_available_date = '2020-12-10';
$product_sku=mysqli_real_escape_string($conn,'someother_value');
echo $product_sku.' '.$product_available_date.'<br>';
$stmt->execute();
$stmt->close();
$conn->close();

Expected result:
----------------
I expect that the value for the variable to be updated in the bind
statement as it correctly happen within a loop without the need to close
the first statement after execution and redeclaring the prepared
statement.


Actual result:
--------------
When written on two lines, and even when unsetting the date, the new
value for the date is not passed on to the prepared statement event
though the string is correctly passed.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=80257&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=80257&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=80257&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=80257&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=80257&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=80257&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=80257&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=80257&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=80257&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=80257&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=80257&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=80257&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=80257&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=80257&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=80257&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=80257&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=80257&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=80257&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#229748) next »