|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13008 Multiple update/inserts fail
Submitted: 2001-08-28 16:01 UTC Modified: 2002-11-01 10:04 UTC
Avg. Score:4.0 ± 0.7
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (33.3%)
From: Brian_Teravskis at Cargill dot com Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.0.6 OS: Linux 2.2.12-20 Red Hat 6.1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: Brian_Teravskis at Cargill dot com
New email:
PHP Version: OS:


 [2001-08-28 16:01 UTC] Brian_Teravskis at Cargill dot com
I'm using FreeTDS 0.51 to access an MSSQL 7.0 pl1 database server. I can use PHP to SELECT information from the database with no problems. I'm having problems with multiple insert/updates done to the database in sequence.

My algorithm attempts to insert/update several rows of data into the database after an HTTP put. It will first attempt to do an SQL insert, and if that errors due to duplicate key restraints it will do an SQL update.

I'm finding that it will do the first update, but after that nothing appears to work unless I close the connection to the database and reopen it again. While this works in a small installation, I can see problems with hundreds of database updates per minute constantly opening and closing connections for each row updated.

I can do multiple SQL inserts in sequence with no problems. It is when the key restraint warning occurs and I do an update.

I have the code if interested.

Here is my PHP configure line:

./configure --with-mysql --with apxs=/usr/local/apache/bin/apxs --with-gd --with-mssql=/usr/local/freetds --with-sybase=/usr/local/freetds --enable-track-vars



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-17 02:12 UTC]
Is this still a valid bug in the recent PHP releases?
 [2002-08-26 15:38 UTC] Brian_Teravskis at Cargill dot com
I will check within the next week or two to verify.
 [2002-10-09 11:59 UTC]
Please try using this CVS snapshot:
For Windows:

If the problem still occures try upgrading to freetds-0.53 and seeing if that'll solve the problem.
 [2002-10-25 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-10-30 03:59 UTC] loeffler at medi-bench dot de
Im am using Windows NT and PHP 4.2.3 and experience the same problems with MS SQL Server 2000: 

i try to do multiple inserts in one query:

$sql = " INSERT INTO tbl (col1, col2) VALUES( $int1, '$str1');
INSERT INTO tbl (col1, col2) VALUES( $int2, '$str2'); ..."


the thing is: one query with more than one insert works, the data is is in the DB. But all others fail. It also works if I do only one insert at the time. 

Even it works, if I put all inserts in one string and do 10000 inserts with one query.
I see a problem here, because the amount of data can grow very large. so there are probably some restrictions to the contents of a string-Variable and the String-Length of a query.

I dont understand, why it is not possible to do a second query after inserting more then one lines... 

 [2002-10-30 08:04 UTC] Brian_Teravskis at Cargill dot com
I'm trying to recreate the problem, but unfortunately I no longer have the system that I originally had the problem on. I only have available an HP-UX 11.0 system and a Mandrake 8.2 system, and I'm having all kinds of problems building PHP on the HP-UX system. I have just about got it built except for some GD shared library problems. Based upon Chris's last report the problem still exists. Hopefully I will be able to test again by the end of the week.
 [2002-10-30 08:08 UTC]
Please try using this CVS snapshot:
For Windows:

 [2002-11-01 09:59 UTC] Brian_Teravskis at Cargill dot com
OK, I know that a lot of things changed in this test, sorry about that - too much time elapsed I guess... I have the following configuration:

Mandrake 8.2 system
Apache 2.0.43 
FreeTDS 0.60
PHP 4.3.0-dev (latest snap)
   PHP API  20020307  
   PHP Extension  20020429  
   Zend Extension  20021010  

'./configure' '--with-apxs2=/usr/local/apache2/bin/apxs' '--with-gd' '--with-zlib' '--with-jpeg' '--with-png' '--with-mssql' '--with-sybase=/usr/local' '--enable-track-vars' '--with-mysql' 

With that setup all apears to work OK now. I can have a failing insert due to a key restraint in the database table and still do updates and other inserts without having to close the connection.

Thanks for the help and your patience with my getting around to testing it.
 [2002-11-01 10:04 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.

User reports that the problem has been fixed.
 [2003-02-03 05:25 UTC] francis_tudlong at yahoo dot com
//im coding this code to update multiple records but how come it will only update one record wherein it is the first record...please help...thanks
//load old names and project handled and delete entries
for($a=0; $a < $tempcount; $a++)
$test="select * from employlist where employlist.fname='".$temphandle[$a]."'";
		 for($cnt=0;$cnt < $hcnttemp; $cnt++){
			 	}else{  $tempvalue.=$htemp[$cnt].","; }
		   }else{  $del++; }	
		$Query  = "Update  employlist set employlist.projects='". $tempvalue."' where employlist.fname='".$temphandle[$a]."'";
		if(!$save) print "did not save";
$display = null;
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jun 13 21:01:33 2024 UTC