php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #57682 Error when using the same variable name more then once for a prepared statement
Submitted: 2007-05-24 12:48 UTC Modified: 2007-05-25 16:24 UTC
From: mattthewv at ca dot ibm dot com Assigned:
Status: Not a bug Package: ibm_db2 (PECL)
PHP Version: 5.2.1 OS: Linux
Private report: No CVE-ID: None
 [2007-05-24 12:48 UTC] mattthewv at ca dot ibm dot com
Description:
------------
If you use the same variable name for prepared statements with in the same block of code a PHP warning is produced and the execute statement will fail on the second prepare statement.

Reproduce code:
---------------
<?php
$db2conn = db2_connect("SAMPLE", "", "");

$query = "Select TABLE_CATALOG, TABLE_NAME From SYSIBM.TABLES";
$stmt = db2_prepare($db2conn, $query);
if(db2_execute($stmt))
{
  $a_result = db2_fetch_both($stmt);
   print("\n" . $a_result[0] . "." . $a_result[1] . "\n\n");
}
db2_free_result($stmt);
db2_free_stmt($stmt);

$query = "Select TABLE_CATALOG, TABLE_NAME From SYSIBM.TABLES";

$stmt = db2_prepare($db2conn, $query);
if(db2_execute($stmt))
{
  $a_result = db2_fetch_both($stmt);
   print("\n" . $a_result[0] . "." . $a_result[1] . "\n\n");
}
db2_free_result($stmt);
db2_free_stmt($stmt);
?>

Expected result:
----------------
SAMPLE.CATALOG


SAMPLE.CATALOG



Actual result:
--------------
SAMPLE.CATALOG


Warning: db2_execute(): More parameters bound than present in C:\testbed\SameNameTest.php on line 18

Warning: db2_execute(): Parameters not bound in C:\testbed\SameNameTest.php on line 18


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-25 16:24 UTC] opendev at us dot ibm dot com
Matthew,

We tried reproducing this bug but were unable to see any problems.  We attempted this with PHP 5.2.1 and PHP 5.2.2 on Linux.  We were using the latest IBM_DB2 code.  Can you please ensure that you are using the latest IBM_DB2 driver code?  Please let us know if you are still not able to resolve this issue.  Thank you.

--Kellen
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Dec 08 22:03:36 2021 UTC