|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #685 odbc_exec doing duplicate, out-of-order calls
Submitted: 1998-08-22 23:35 UTC Modified: 1999-10-03 06:41 UTC
From: z-kimmel at uiuc dot edu Assigned:
Status: Closed Package: ODBC related
PHP Version: 3.0.3 OS: NT 4
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: z-kimmel at uiuc dot edu
New email:
PHP Version: OS:


 [1998-08-22 23:35 UTC] z-kimmel at uiuc dot edu
I am writing code to insert a person's ID number and age into a database. The following code gives wacky results!

$connection = odbc_connect("mydb","myname","mypassword");

#insert a new age into the database

$query="select * from mytable where personID=" . strval($personID) . " and personAge=" . strval($age) . ";";
$result = odbc_exec($connection,  $query);


$query="insert into mytable(personID, personAge) values (" .
	strval($personID) . "," . strval($age) . ");";
$result = odbc_exec($connection,  $query);
Establishing the connection works fine. (The same problem occurs with odbc_pconnect.)

If I remove everything after the #****, then I get the expected result:
No rows found
But if I include the lines after the #****, I get the following result (for personID=3 and personAge=50, where these values are not already in the database):
PersonID  PersonAge
 3         50
Warning: SQL error: [Sybase][ODBC Driver]Integrity constraint violation: primary key for table 'mytable' is not unique, SQL state 23000 in
SQLExecDirect in makenewaccount on line 45
Somehow, the "insert" statement is being executed BEFORE the "select" statement is executed, and then the "insert" statement is executed AGAIN. Maybe this is due to some multithreading effect?

The data does enter the database successfully. The code behavior described above does not seem to be due to the database itself, because if I enter the exact same commands in a different SQL interpreter on the same database all is well.

I am using Win32 PHP 3.0.3 and Apache.

--Zeba Kimmel,


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [1999-10-03 06:41 UTC] kara at cvs dot php dot net
Seems to be fixed
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Sep 18 18:01:26 2020 UTC