Bug #78932 [Opn->Ver]: Cannot fetch mysqli_prepare error if $statement variable reused
| From: | nikic@php.net | Date: | Mon, 09 Dec 2019 08:26:16 +0000 |
| Subject: | Bug #78932 [Opn->Ver]: Cannot fetch mysqli_prepare error if $statement variable reused | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-224153@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78932&edit=1
ID: 78932
Updated by: nikic@php.net
Reported by: craig at craigfrancis dot co dot uk
-Summary: mysqli_prepare oddity
+Summary: Cannot fetch mysqli_prepare error if $statement
variable reused
-Status: Open
+Status: Verified
Type: Bug
Package: MySQLi related
-PHP Version: 7.4.0
+PHP Version: 7.3.12
Block user comment: N
Private report: N
New Comment:
Also reproduces on older PHP versions.
Previous Comments:
------------------------------------------------------------------------
[2019-12-08 21:27:49] craig at craigfrancis dot co dot uk
Description:
------------
When running the following test script, the error is not correctly shown.
But if you un-commented the
$statement = false line, then it works.
It's as though the $statement variable is not being properly replaced.
Test script:
---------------
<?php
$link = mysqli_connect('localhost', 'username', 'password',
'database');
$statement = mysqli_prepare($link, 'SELECT 1');
// $statement = false;
$statement = mysqli_prepare($link, 'SELECT 1 FROM this_table_does_not_exist');
if (!$statement) {
exit(mysqli_errno($link) . ': ' . mysqli_error($link));
}
?>
Expected result:
----------------
1146: Table 'database.this_table_does_not_exist' doesn't exist
Actual result:
--------------
0:
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78932&edit=1