php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41350 Error in my_thread_global_end()
Submitted: 2007-05-10 12:12 UTC Modified: 2010-10-16 00:01 UTC
Votes:304
Avg. Score:4.5 ± 0.8
Reproduced:282 of 283 (99.6%)
Same Version:160 (56.7%)
Same OS:175 (62.1%)
From: graham at directhostinguk dot com Assigned: scottmac
Status: Closed Package: MySQL related
PHP Version: 5.2.6 OS: *
Private report: No CVE-ID:
 [2007-05-10 12:12 UTC] graham at directhostinguk dot com
Description:
------------
This closed PHP bug: http://bugs.php.net/bug.php?id=41316

MySQL Bug: http://bugs.mysql.com/bug.php?id=25621

Error in my_thread_global_end(): 1 threads didn't exit 

I have the same issue even when the script doesn't call any MySQL, but this error only happens when using fast-cgi If I run php 5.2.2 ISAPI the problem goes away.

I think this is a php bug

It seems to me that the problem lies in the PHP dll "php_mysql.dll" as it is opening the threads but not telling MySql to close them.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-18 10:30 UTC] e_remove_paine at lastfrontiers dot com
With PHP5.2.2, and MySQL5.0.41 under Windows XP (IIS5.1) I can reproduce this by simply creating a normal html page (no php tags) with a .php extension.

Error in my_thread_global_end(): 1 threads didn't exit
 [2007-05-29 17:04 UTC] php at stock-consulting dot com
I receive the message as well, when running PHP 5.2.2 from the command line, so definitely no IIS-related issue.

The php_mysql.dll is loaded as an extension, but no functions from the library are called by the application, so most likely no MySQL issue. The message appeared after the PHP version update; no MySQL update was performed. A clear indication, IMHO, the something went wrong on the PHP side.
 [2007-05-31 08:15 UTC] louis at steelbytes dot com
repro on win2k3.

reverting libmysql.dll to 5.2.1 fixes it.
 [2007-06-12 16:31 UTC] chris at crgs dot co dot uk
Still a problem on PHP 5.2.3 under Windows Server 2003 / IIS 6 / MySQL 5.0.41. Can be fixed by copying libmysql.dll from PHP 5.2.1.

Seems as if neither side wants to take ownership of the bug. MySQL people seem to say it's a PHP issue (see http://bugs.mysql.com/bug.php?id=25621), but not much seems to be happening here.

Can someone please fix this bug before the next release of PHP?
 [2007-06-15 04:19 UTC] louis at steelbytes dot com
see http://bugs.mysql.com/bug.php?id=25621 for mysql bug report on same prob
 [2007-06-18 19:33 UTC] curthenderson at hotmail dot com
I have found that this error will come up if you are using short php opening tags <? and do not have that option turned on in your php.ini.
 [2007-06-19 16:26 UTC] chris at crgs dot co dot uk
Re short_open_tag option

I have tested on my server with short_open_tag set to both 'on' and 'off' and get this problem whatever happens with PHP 5.2.3.

The error occurs even with this page:
<?php phpinfo(); ?>
 [2007-06-20 15:08 UTC] scottmac@php.net
Is everyone running a CGI implementation or ISAPI?
 [2007-06-21 10:51 UTC] chris at crgs dot co dot uk
Am using CGI here (php-cgi.exe in IIS6)

There appears to be some action on the MySQL bug...
 [2007-06-24 09:37 UTC] ysangkok at gmail dot com
I'm experiencing the same problem with 5.2.3. Using CGI on IIS5.

I fixed it by using the dll from 5.2.1.
 [2007-06-26 11:38 UTC] maxfm at abv dot bg
Just go to the end of php.ini
Change:
[PHP_MYSQL]
extension=php_mysql.dll
to:
;[PHP_MYSQL]
;extension=php_mysql.dll

Then go to:
;extension=php_mysql.dll
and enable it:
extension=php_mysql.dll
 [2007-06-26 12:00 UTC] scottmac@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

I've committed a fix that should have resolved this.
 [2007-06-28 10:02 UTC] chris at crgs dot co dot uk
Scott is already aware of this, but I tried the snapshot from 12:30 27-06-2007 and it didn't fix the problem. However this might be because the fix from the MySQL bug is necessary as well, and currently the PHP snapshots contain libmysql.dll from PHP 5.0.37 rather than 5.0.45 (which is apparently the one we need).

We may need to wait for MySQL to release their new version, and for the new libmysql.dll to make its way across to PHP, before the bug will be 'properly' fixed.
 [2007-07-13 10:16 UTC] tony2001@php.net
So that we won't forget.
http://server.macvicar.net/patches/php-bug41350.patch
 [2007-07-18 23:27 UTC] aaronbair at hotmail dot com
CLI and FAST-CGI can not handle persistent MySQL connections.  How can an unloaded processes remember a connection?

Turn that option off in php.ini and the error goes away.

mysql.allow_persistent = Off

The real problem here is that this option is set On in php.ini-recommended
 [2007-07-19 11:16 UTC] ng dot sick dot no at gmail dot com
Tried the latest CVS snaps today (php5.2-win32-200707120030.zip) with php5apache22.dll, MySQL 5.0.45 Server on Windows XP, but Apache 2.2.4's log still shows up:

Error in my_thread_global_end(): 1 threads didn't exit
 [2007-07-24 10:24 UTC] nick dot dixon at gmail dot com
I see the same with 5.2.3 on Windows 2000 whenever php_mysql or php_mysqli (or both) are enabled

So either the fault is in both php_mysql.dll AND php_mysqli.dll, or it's a problem with the MySQL client library (libmySQL.dll).

Setting mysql.allow_persistent = Off makes no difference.

MySQL version is 5.0.45, with the libmySQL.dll copied to a directory that's in the PATH (the PHP ext directory)

Minimal test case using PHP cli:
php -v
PHP 5.2.3 (cli) (built: May 31 2007 09:37:22)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Now if I run the CLI and send EOF:

php
^Z
   (...pause of about 6 seconds...)
Error in my_thread_global_end(): 1 threads didn't exit
 [2007-07-24 10:45 UTC] scottmac@php.net
Assigning to edink since we need to upgrade the bundled MySQL libraries.
 [2007-08-02 14:01 UTC] phpuser at gmail dot com
Please don't forget about php_pdo_mysql.dll!
 [2007-08-08 01:23 UTC] xavier at codewordx dot com
So, it looks like this problem has not been fixed. Has it?

Is there a CVS snap to php 521? Or can somebody just email me the correct libmysql.dll? It would be great to finally fix this issue.

Thanks,
Xavier
 [2007-08-14 21:45 UTC] sghasemi at mail dot com
I am getting this error using the PHPMailer to send SMTP e-mails on a Windows XP PC. It send the mail OK but at the end gives me the error:
"Error in my_thread_global_end(): 1 threads didn't exit"
Any ideas?
 [2007-08-16 06:38 UTC] a at asdf dot com
I get this bug when running a Wiki, through IIS6 on Win2k3. I get 3-4 threads didn't exit. Other than that, the Wiki works fine. I am using MySQL, but I was getting it yesterday, when I was using PostgreSQL. (insert DA-duh--DUMMM!!! sound for extra suspense).

Setting the mysql_allow_persistent variable to off makes no difference for me either.

I replaced the libmysql.dll with one from PHP5.2.1, but then the Wiki reported that it couldn't access php_mysql.dll because access is denied. I replaced the file again and rebooted the server and that problem is gone, but I'm still getting 3-4 threads didn't exit. I tried replacing the file again, and get an exception with a huge stack trace, so I went back to using the 5.2.3 file.

Btw, Win2k3 and PHP5 are both 64bit installs.


Also, YOU IDIOTS! Spelling out your email address (ie. dudeguy at domain dot tld) is *not* going to fool an email address harvester! You need to be more creative!
dude%guy-@7-h0tXmail-d_ot/c*m
 [2007-08-19 07:27 UTC] thorsten at phpmyfaq dot de
This bug is still occurs in PHP 5.2.4-RC2 because libmysql.dll is still the wrong one. It works with libmysql.dll taken from MySQL 5.0.45.
 [2007-08-19 12:12 UTC] scottmac@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows (zip):
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip

For Windows (installer):

  http://snaps.php.net/win32/php5.2-win32-installer-latest.msi

The libraries were updated yesterday afternoon to 5.0.45.
 [2007-08-21 16:13 UTC] romain dot burot at laposte dot net
I try this CVS snapshot And I've got the same problem...
And I don't use Mysql Database
I'm with win2003SP2 with IIS6
PHP Version 5.2.3 Not Isapi but CGI
mysqli
MysqlI Support	enabled
Client API library version 	5.0.45
Client API header version 	5.0.45
MYSQLI_SOCKET 	/tmp/mysql.sock

Directive	Local Value	Master Value
mysqli.default_host	no value	no value
mysqli.default_port	3306	3306
mysqli.default_pw	no value	no value
mysqli.default_socket	no value	no value
mysqli.default_user	no value	no value
mysqli.max_links	Unlimited	Unlimited
mysqli.reconnect	Off	Off
 [2007-08-21 16:37 UTC] scottmac@php.net
Does your phpinfo show 5.2.3 or 5.2.4-RC2?

The MySQL library version looks correct but the code to correctly use the library wasn't added until after 5.2.3 was released.
 [2007-08-22 01:38 UTC] ng dot sick dot no at gmail dot com
Looks like for some reason, the Client API library version of the snap is 5.0.24.


PHP Version 5.2.4RC3-dev 

Build Date  Aug 21 2007 20:03:47  
Loaded Configuration File  C:\php\php.ini  

mysql
MySQL Support enabled 
Active Persistent Links  0  
Active Links  0  
Client API version  5.0.24  

Directive Local Value Master Value 
mysql.allow_persistent On On 
mysql.connect_timeout 60 60 
mysql.default_host no value no value 
mysql.default_password no value no value 
mysql.default_port no value no value 
mysql.default_socket no value no value 
mysql.default_user no value no value 
mysql.max_links Unlimited Unlimited 
mysql.max_persistent Unlimited Unlimited 
mysql.trace_mode Off Off 

mysqli
MysqlI Support enabled 
Client API library version  5.0.24  
Client API header version  5.0.45  
MYSQLI_SOCKET  /tmp/mysql.sock  

Directive Local Value Master Value 
mysqli.default_host no value no value 
mysqli.default_port 3306 3306 
mysqli.default_pw no value no value 
mysqli.default_socket no value no value 
mysqli.default_user no value no value 
mysqli.max_links Unlimited Unlimited 
mysqli.reconnect Off Off
 [2007-08-22 15:38 UTC] dj02 dot net at nbl dot fi
I updated to: 5.2.4RC3-dev (08-22-2007, SNAP).

And libraries are updated.
----------------------------------------------------
mysql
----------
MySQL Support	enabled
Active Persistent Links 	0
Active Links 	0
Client API version 	5.0.45

Directive	Local Value	Master Value
mysql.allow_persistent	On	On
mysql.connect_timeout	60	60
mysql.default_host	no value	no value
mysql.default_password	no value	no value
mysql.default_port	3306	3306
mysql.default_socket	no value	no value
mysql.default_user	no value	no value
mysql.max_links	Unlimited	Unlimited
mysql.max_persistent	Unlimited	Unlimited
mysql.trace_mode	Off	Off

mysqli
----------
MysqlI Support	enabled
Client API library version 	5.0.45
Client API header version 	5.0.45
MYSQLI_SOCKET 	/tmp/mysql.sock

Directive	Local Value	Master Value
mysqli.default_host	no value	no value
mysqli.default_port	3306	3306
mysqli.default_pw	no value	no value
mysqli.default_socket	no value	no value
mysqli.default_user	no value	no value
mysqli.max_links	Unlimited	Unlimited
mysqli.reconnect	Off	Off
 [2007-08-24 17:18 UTC] acosta at mauricio dot net dot ar
Hi,

I got this issue with iis 6 in xp os.  I install the cvs snapshot you referer, with cgi i got the error, but in isapi appears that it dissapears.
 [2007-08-29 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2007-08-31 18:25 UTC] phpuser at gmail dot com
Error remains in PHP 5.2.4
 [2007-09-03 15:29 UTC] astorni at softhome dot net
I upgraded from 5.0.4 to 5.2.4, and I saw this bug for the first time.
But for me, the threads were 7 (no idea what it means):

7 threads didn't exit 

The page displayed correctly, but did not stop, and after a few seconds of delay I get the message.
 [2007-09-03 15:48 UTC] astorni at softhome dot net
For me, it did not help replacing the php_mysql.lib with the old one from versions 5.2.0 or 5.2.1, so I have no workaround.
 [2007-09-05 12:05 UTC] lferro at teladigital dot pt
Using PHP Version 5.2.4 and MySQL 5.0.37 community version, on a WinXP box, i got this error.

The workaround was just to update the libmySQL.dll that resides in the php directory with the one shipped with the MySQL.

Not perfect... but...

;)
 [2007-09-05 14:40 UTC] richard at vottle dot com
I am having the same problem with PHP 5.2.4. I have tried replacing libmysql.dll from PHP 5.1.2, and also took the libmysql.dll from my instance of MySQL 5.0.15-nt - nothing is solving the problem except reverting back to PHP 5.1.2 in its entirity.
 [2007-09-05 19:03 UTC] richard at vottle dot com
Temporary dyslexia mixed in with too many archived versions of PHP and you are bound to get things mixed up. 

Taking libmysql.dll from php v 5.2.1 (and not 5.1.2) and replacing the libmysql.dll in php 5.2.2->4 works fine.

Would still be nice to have a proper working copy in the actual release though ;)
 [2007-09-10 05:49 UTC] thorsten at phpmyfaq dot de
This bug still occurs with PHP 5.2.4 and libmysql.dll from PHP 5.2.4 package and from MySQL 5.0.45 package when using ext/mysql.
 [2007-09-10 22:49 UTC] scottmac@php.net
ISAPI, CGI, CLI or FCGI?

How are you producing it do you have to do anything specific or does everything produce it?

I can't reproduce this on my test box apart from with -i / -m but thats since been fixed in CVS by dmitry.
 [2007-09-11 12:01 UTC] thorsten at phpmyfaq dot de
It's the Apache 2.0 Handler on my system.

We're doing a SELECT query on a really big 2 GB table with PEAR::MDB2 with ext/mysql.
 [2007-09-12 15:25 UTC] Chicken at TheMooFarm dot com
This is sucking real hard

I am using 
Mysql Ver5.041-community-nt
apache_2.2.4-win32-x86-no_ssl
php-5.2.4-win32-installer.msi

TRIED ALSO from Mysql's site
php_5.2.0_mysqli_5.0.27-win32.zip

I do a install of PHP Version 5.2.4
I only enable 3 extensions

[PHP_CURL]
extension=php_curl.dll
[PHP_GD2]
extension=php_gd2.dll
[PHP_MYSQL]
extension=php_mysqli.dll

I have tried replacing the Mysql DLL shipping with PHP
with the Mysql Connectoid and the DLL that ships with Mysql
libmysql.dll

The GD2 Extension Loads
the Curl and Mysql Dlls CHOKE

APACHE ERROR LOG
PHP Warning:  PHP Startup: Unable to load dynamic library 'D:\\Apache2\\php\\ext\\php_curl.dll' - The specified module could not be found.\r\n in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'D:\\Apache2\\php\\ext\\php_mysqli.dll' - The specified module could not be found.\r\n in Unknown on line 0



If PHP can load GD without problems

but it cant load Curl or Mysql or Mysqli
It sounds like a problem in the compiled source code
 [2007-09-12 15:51 UTC] Chicken at TheMooFarm dot com

 [2007-09-14 06:53 UTC] csharp dot net dot 2007 at hotmail dot com
Error in my_thread_global_end(): 1, Error in my_thread_global_end(): 3

I have the same issue. I opened php.ini and disabled the PHP_IISFUNC like this :
;[PHP_IISFUNC]
;extension=php_iisfunc.dll 

The problem goes away.
 [2007-09-17 07:16 UTC] thorsten at phpmyfaq dot de
The bug still exists with today's build:

zend_mm_heap corrupted
Error in my_thread_global_end(): 252 threads didn't exit
 [2007-09-18 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2007-09-18 06:13 UTC] wangyi6854 at sohu dot com
I got the problem on Win2k3, IIS6, php5.2.4

PHP Version 5.2.4 

System  Windows NT BANDAO-17 5.2 build 3790  
Build Date  Aug 30 2007 07:05:48  
Configure Command  cscript /nologo configure.js "--enable-snapshot-build" "--with-gd=shared"  
Server API  CGI/FastCGI  
Virtual Directory Support  enabled  
Configuration File (php.ini) Path  C:\WINDOWS  
Loaded Configuration File  F:\PHP5\php.ini  
PHP API  20041225  
PHP Extension  20060613  
Zend Extension  220060519  
Debug Build  no  
Thread Safety  enabled  
Zend Memory Manager  enabled  
IPv6 Support  enabled  
Registered PHP Streams  php, file, data, http, ftp, compress.zlib  
Registered Stream Socket Transports  tcp, udp  
Registered Stream Filters  convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, zlib.*  

mysql
MySQL Support enabled 
Active Persistent Links  0  
Active Links  0  
Client API version  5.0.45  

Directive Local Value Master Value 
mysql.allow_persistent On On 
mysql.connect_timeout 60 60 
mysql.default_host no value no value 
mysql.default_password no value no value 
mysql.default_port no value no value 
mysql.default_socket no value no value 
mysql.default_user no value no value 
mysql.max_links Unlimited Unlimited 
mysql.max_persistent Unlimited Unlimited 
mysql.trace_mode Off Off 


mysqli
MysqlI Support enabled 
Client API library version  5.0.45  
Client API header version  5.0.45  
MYSQLI_SOCKET  /tmp/mysql.sock  

Directive Local Value Master Value 
mysqli.default_host no value no value 
mysqli.default_port 3306 3306 
mysqli.default_pw no value no value 
mysqli.default_socket no value no value 
mysqli.default_user no value no value 
mysqli.max_links Unlimited Unlimited 
mysqli.reconnect Off Off 

Error in my_thread_global_end(): 1 threads didn't exit
 [2007-09-18 18:58 UTC] chadworsham at hotmail dot com
Error in my_thread_global_end(): 3 threads didn't exit 

D:\>ver
Microsoft Windows XP [Version 5.1.2600]
C:\php5>php.exe -v
PHP 5.2.4 (cli) (built: Aug 30 2007 07:06:31)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 3 threads didn't exit

mysql> status
--------------
mysql  Ver 14.13 Distrib 6.0.2-alpha, for Win32 (ia32)

Does anyone know of a REAL fix?
 [2007-09-19 19:36 UTC] phpbug at povaddict dot com dot ar
I'm running:
PHP 5.2.4 (cli) (built: Aug 30 2007 07:06:31)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

with mysqli enabled, on a Windows XP machine.

A simple way to reproduce it is running php -r "sleep(60);" and pressing Ctrl-C before it quits on its own. It takes over 5 seconds to actually quit, and then displays "Error in my_thread_global_end(): 1 threads didn't exit". Of course, you need some MySQL library enabled in php.ini...
 [2007-09-19 19:45 UTC] phpbug at povaddict dot com dot ar
I forgot to mention:
MySQL Ver 14.12 Distrib 5.0.45, for Win32 (ia32)

I tried renaming the libmysql.dll inside PHP folder and replacing it with the one from MySQL folder, didn't help. I also read somewhere that 5.0.42 should have the fix; obviously that's not the case.

Also, derick said on another PHP bug that "We don't call my_thread_init, or anything starting with my_thread." A reply from mysql bug comments: "my_thread_init() is called indirectly from mysql_init()".
 [2007-09-19 21:27 UTC] scottmac@php.net
ctrl+c causes a SIGINT which isn't handled by PHP so the module shutdown isn't run and we can't clean up. So that would be expected behaviour.

libmysql for 6.0 doesn't work yet as far as I know.

Those seeing the error on CGI / FCGI should try a 5.2.5 snapshot as there was another bug that caused module shutdown now to be executed for -v and -i.

I need a consistent reproduce case to look further at this. I can't reproduce this with 5.2.5-dev with MySQL 5.0.45 with MySQL, MySQLi and pdo_mysql loaded.

Test cases if you please.
 [2007-09-25 17:54 UTC] daniel dot gaddis at tlc dot state dot tx dot us
php -v returned the error using PHP 5.2.5-dev (cli) (built: Sep  9 2007 12:04:32). See mysql and apache version info below.



F:\php>php -v
PHP 5.2.5-dev (cli) (built: Sep  9 2007 12:04:32)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 1 threads didn't exit



F:\MySQL\bin>mysqladmin --user=xxxx --password=xxxx version
mysqladmin  Ver 8.41 Distrib 5.0.45, for Win32 on ia32
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.45-community-nt-log
Protocol version        10
Connection              localhost via TCP/IP
TCP port                3306
Uptime:                 9 min 57 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 12  Flush tables: 1  Open tabl
es: 6  Queries per second avg: 0.007



F:\Program Files\Apache Group\Apache>apache.exe -v
Server version: Apache/1.3.37 (Win32)
Server built:   Jul 27 2006 15:23:00
 [2007-09-25 17:55 UTC] daniel dot gaddis at tlc dot state dot tx dot us
php -v returned the error using PHP 5.2.5-dev (cli) (built: Sep  9 2007 12:04:32). See mysql and apache version info below.



F:\php>php -v
PHP 5.2.5-dev (cli) (built: Sep  9 2007 12:04:32)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 1 threads didn't exit



F:\MySQL\bin>mysqladmin --user=xxxx --password=xxxx version
mysqladmin  Ver 8.41 Distrib 5.0.45, for Win32 on ia32
Copyright (C) 2000-2006 MySQL AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

Server version          5.0.45-community-nt-log
Protocol version        10
Connection              localhost via TCP/IP
TCP port                3306
Uptime:                 9 min 57 sec

Threads: 1  Questions: 4  Slow queries: 0  Opens: 12  Flush tables: 1  Open tabl
es: 6  Queries per second avg: 0.007



F:\Program Files\Apache Group\Apache>apache.exe -v
Server version: Apache/1.3.37 (Win32)
Server built:   Jul 27 2006 15:23:00
 [2007-09-26 10:29 UTC] chris at crgs dot co dot uk
Have just tried the latest PHP 5.2 snapshot from http://snaps.php.net/ - *still* doesn't work.

I am reproducing this on the most basic machine I can, a Windows 2000 Professional VM (Virtual PC 2007) with all security updates. There is nothing else on the PC, not even a MySQL install, just PHP (see below for settings), but I am still getting the error.

However the error *DOES NOT ALWAYS OCCUR*, especially when I just use 'php -v'. Sometimes I have to run this command quite a few times before the error occurs - it comes up maybe 2 times out of 10. When I run it on my main box, outside the virtual machine, 'php -v' doesn't seem to trigger the error much at all: however, using a slightly more complicated command like 'php-cgi test.php' where test.php contains '<?php phpinfo(); ?>' triggers the error more often, even outside the VM.

Are we looking at a race condition? Can people post the specification of their boxes as well? Mine is an Intel Pentium D 3.4Ghz (dual core) w/ 2GB RAM. Of course inside the virtual machine there's only one processor, which might explain partly why the error occurs more often inside the VM, although I don't think it's a single/multi-processor issue at heart, as I can still repro the issue on a dual core PC, just less often. Perhaps it's only an issue on slower machines? Scott, what's your spec?

Here is what I did:

Download php5.2-win32-200709260830.zip from http://snaps.php.net/
Extract to C:\PHP
Append ';C:\PHP' to the PATH environment variable
Add PHPRC environment variable, set to 'C:\PHP\php.ini'
Copy php.ini-recommended to php.ini
	Change the following settings:
		extension_dir = "c:\php\ext\"
		extension=php_mysql.dll
Run 'c:\PHP\php-cgi.exe -v'

Returns (after a roughly 2 second pause):
PHP 5.2.5-dev (cli) (built: Sep 26 2007 04:04:42)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 1 threads didn't exit

By the way, I also tried setting mysql.allow_persistent = Off, as suggested in some of the comments, but it didn't help in either environment (VM or real).
 [2007-09-26 13:31 UTC] w dot ashcroft at redfoxuk dot com
Confirmed on Windows 2003 with IIS6 using MS FastCGI; using libmysql.dll (v5.0.22) from PHP 5.2.1 fixes the problem and massively improves PHP speed globally.
 [2007-09-27 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2007-09-28 14:40 UTC] ricardo dot rodrigues at istimeless dot pt
Error in my_thread_global_end(): 1 threads didn't exit

 I don't think it's a MySQL error, since i'm not using it at all. I have no active instances of MySQL running. I'm using PHPLIB Templates and the code is very simple:

<?php
include ("Includes/template.inc");

$index = new Template("Templates");
$index->set_file("f_index", "index.tpl");

$index->set_var("page_title", "INDEX");

$index->parse("o_index", "f_index");
$index->p("o_index");  
?>

I'm running PHP 5.4.2 with MySQL 5.0.45, under Windows XP Pro SP2 with IIS 5.1.
 [2007-09-30 02:56 UTC] joecosmoj at gmail dot com
By commenting out :
;extension=php_mysql.dll
and restarting mysql
THE BUG DISAPPEARED
dll version=5.2.5.5
Special build descriptor = "-dev"
 [2007-09-30 12:42 UTC] 256512 at gmail dot com
To reproduce the error on my setup (Windows XP SP2, PHP 5.2.4):
- in php.ini enable any of the following extensions: php_mysql.dll, php_pdo_mysql.dll, php_mysqli.dll
- execute "php.exe" on command line
- press Ctrl+C

After a significant pause (~5 seconds), the error message appears:
"Error in my_thread_global_end(): 1 threads didn't exit"

Disabling php_mysql.dll, php_pdo_mysql.dll, php_mysqli.dll in php.ini "fixes" the issue (php.exe exits immediately, without any errors).

Disabling MySQL extensions eliminates a significant pause (~5 seconds) at exit with scripts that connect to a PostgreSQL database (yes, PostgreSQL, not MySQL). Without error messages, though. A minimal script to reproduce this, when any of the MySQL extensions are enabled, is a single pg_connect() statement. When MySQL extensions are disabled, the script exits immediately.
 [2007-10-03 17:14 UTC] mike at wardfam dot org
Copying libmysql.dll from 5.2.1 fixed this issue for me also. Configuration: Windows 2003 x64 SP2, PHP 5.2.4, CGI/FastCGI
 [2007-10-04 11:19 UTC] thorsten at phpmyfaq dot de
Hi all,

the current PHP 5.2.5-dev package from http://snaps.php.net with the bundled libmysql.dll fixes this issue.

Best regards
Thorsten
 [2007-10-04 17:14 UTC] temp4 at scottpreston dot com
I just tried this and it does not fix the issue. I overwrote and unloaded all DLLs, still 5 second delay.
 [2007-10-05 10:04 UTC] chris at crgs dot co dot uk
Confirmed. Have just tried php5.2-win32-200710050830.zip and the problem is not solved. Repro as per my previous post above. Results the same:

C:\php>php-cgi.exe -v
PHP 5.2.5-dev (cgi-fcgi) (built: Oct  5 2007 04:04:23)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 2 threads didn't exit
 [2007-10-09 20:27 UTC] cranderson at att dot net
Confirmed. Have just tried php5.2-win32-200710092030.zip and the problem is not solved.

OS: Windows 2000 Pro
HW: Dual CPU Zeon

Results the same:

C:\php>php-cgi.exe -v
PHP 5.2.5-dev (cli) (built: Oct  9 2007 16:04:34) 
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with DBG v3.2.7, (C) 2000,2007, by Dmitri Dmitrienko
Error in my_thread_global_end(): 1 threads didn't exit

Note: Overwriting the files php_mysql.dll, php_mysqli.dll with those from 5.2.3 works.....

mysql

MySQL Support => enabled
Client API version => 5.0.45

mysqli

MysqlI Support => enabled
Client API library version => 5.0.45
Client API header version => 5.0.36
MYSQLI_SOCKET => /tmp/mysql.sock (this shouldn't be here on Win)
 [2007-10-17 11:07 UTC] anrdaemon at freemail dot ru
Got the same issue. From short investigation, all executables affected, not only PHP-CGI.

Actually, problem in libmySQL bundled with PHP.

Please refer to http://bugs.php.net/bug.php?id=43002 for detailed info.
 [2007-10-18 16:49 UTC] cranderson at att dot net
anrdaemon,

The snapshots being tested here have the 5.0.45 MySQL dll.  Also tested with the dll distributed with MySQL. Also checked loaded dlls with a process explorer. The problem is in the php_mysql.dll and php_mysqli.dll.  This problem can be duplicated with Win2000Pro, not with XP Pro SP2 or Win2003 Server.
 [2007-10-19 19:51 UTC] topgunmm at comcast dot net
This bug also exists for mssql.
 [2007-10-23 14:38 UTC] barrp at hcdat dot com
error occurs sending mail but is email address specific.

If I send to some emails there is consistantly no error.
Other addresses always give the error.

The same php code works on my ISP site but not locally.

Seems like a setup issue on my box.
 [2007-10-25 06:24 UTC] itahmed at hotmail dot com
you can download the libmysql.dll  to replace the current one that comes with php 5.2.4. this is from the 5.2.1 release that works and take care of the error message.

http://www.it-etc.com/2007/10/25/php-error-524-getting-error-error-in-my_thread_global_end-1-threads-didnt-exit/
 [2007-10-25 09:59 UTC] chris at crgs dot co dot uk
itahmed: We are all aware of this solution, but it's not really a long-term one. Eventually we will *need* to use the latest MySQL libraries, and we need the bug fixed before then.
 [2007-10-25 10:35 UTC] scottmac@php.net
I can't reproduce this on XP which is the only Windows environment I have for testing.

Are the people still experiencing problems on Windows 2000 or 2003?
 [2007-10-25 12:28 UTC] noto at ardentsolutions dot co dot za
I tried this and it's not really helping much hey...
I also noticed that this causes the pages to load slower (on IE, IE7).
On firefox the pages load quicker but the error is there...
 [2007-10-25 13:54 UTC] noto at ardentsolutions dot co dot za
My appologies to you all.
The fix works great!
I'm running MySQL 4.1 and PHP 5.2.4 on XP.
My issue was that IE 7 kind of waits for ajax code to finish executing before leaving a page, which is dumb...
 [2007-10-25 16:06 UTC] rburghol at vt dot edu
Error occurs with Postgresql, but only if I instantiate a database connection (using pg_connect).  Even if I do nothing with the connection AND if I explicitly close the connection (pg_close).  Removing the pg_connect makes the error go away, and avoids the ~5 second delay.  I would submit that this is not mysql related, since I have disabled the mysql dll.

PHP Version: 5.2.4
Via FastCGI

System Specs:
Windows XP Service Pack 2
Intel P4 2.8 GHz
 [2007-10-25 17:25 UTC] rburghol at vt dot edu
My apologies as well, the fix DID work, even though I had disabled mysql in php.ini, and no mysql presence was shown in the phpinfo() output, for some reason, mysql stuff must have been loaded anyhow! (perhaps it is precompiled somewhere in the win executable???)

Woohoo! My ajax is now responsive!!!
 [2007-10-30 10:35 UTC] chris at crgs dot co dot uk
Scott, am having this issue on both XP and Server 2003.

What spec machine are you testing on? Can you try this on another machine, or in a virtual machine?
 [2007-11-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2007-11-02 19:47 UTC] ccongdon at congdonweb dot com
Just installed 5.2.4

ISAPI with MySQL and MSSQL installed

IIS5 on Windows 2k SP 3

C:\Documents and Settings\Administrator>d:\php\php -v
PHP 5.2.4 (cli) (built: Aug 30 2007 07:06:31)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 1 threads didn't exit
 [2007-11-13 23:17 UTC] bobbyb98 at gmail dot com
5.2.5 on Windows 2003 Server having the same problem

Was running 5.1.2 fine, and the upgrade isn't allowing any mysql connections.  It appears even though everything is set in the PHP.ini for it to be loaded, it isn't loading.  Not showing up on the phpinfo page or available to any programs.
 [2007-11-14 18:38 UTC] jamesvl at trinitylight dot com
I'm experiencing this on PHP 5.2.5-nts on Windows 2003. Web server doesn't matter since I see the bug just by running "php -m" on the command line.

Enabling either php_mysql.dll or php_mysqli.dll in php.ini causes the bug to appear. Sometimes it takes several runs for "php -m" before I get the delay and then the "Error in my_thread_global_end(): 1 threads didn't exit" message.

Can't use the "fix" to downgrade to an earlier version of libmysql.dll unless a non-threadsafe compile is available somewhere...
 [2007-11-20 16:40 UTC] dkeller at uh dot edu
I'm using php 5.2.5 through cgi on iis6 and windows 2003 server.

I still get the my_thread_global_end() error.  Turning of mysql 
persistent connections in php.ini had no effect.

Rolled back to libmysql.dll 5.0.22, but that obviously is not the 
answer.  Any ideas what should be done for this?  My superiors are 
starting to get a little antsy about this situation, and "php says it's 
mysql's fault and vice versa" isn't helping.

I'll give any information that can help.

Thanks for all the work.
 [2007-11-23 12:43 UTC] andrewm at rochester dot rr dot com
I tried every suggestion on this page to fix this problem (Error in my_thread_global_end(): 1 threads didn't exit) and nothing helped me. It was php_imap.dll that was ther culprit for me. I commented that out in php.ini and everything works great now. Now hopefully I won't need imap before this is fixed.
 [2007-11-27 21:53 UTC] michael at chunkycow dot com dot au
Does anyone know if switching to the new ND driver will fix this?
 [2007-12-03 06:55 UTC] bjohnso1 at usc dot edu dot au
Don't know if anyone else can relate to this, but I had PHP (5.2.4) working with Apache 2.2.4 with no problems.  It was a little while ago now so I'm not absolutely certain of the event sequence, but I'm reasonably sure I installed mySQL 5.0.45 at the same time and saw it come up in the <?php phpinfo(); ?> test script page I created.  I've since started working with mySQL AND installed mySQL Administrator (or the whole tools collection) and now have the error referred to in this bug.

So, I'm reasonably certain that this bug only affected me after installing the Administrator/Query Browser/etc toolset.

Uninstalling the toolset (GUI tools) did not remedy the problem.

Hope this helps.
Ben Johnson.
 [2007-12-04 01:45 UTC] jp at chicagowebexperts dot com
Windows XP, PHP 5.2.5, same issue: "Error in my_thread_global_end(): 1 threads didn't exit"  Typically "1" thread, but sometimes 3.  Running as a CGI.  Problem manifests even if no calls to any MySQL function are made.  Problem disappears if "extension=php_mysql.dll" is commented out.

Noticed that the behavior becomes less frequent (or disappears entirely) the more that your page outputs.  Have a "controller.php" file doing only back-end processing, no client output; bug appears 100% of the time.  Noticed that my index.php file never failed (about 60 lines of HTML outputted), so for the heck of it, put in <? exit; ?> at the very top.  Problem occurs 100% of the time.  Problem never occurs in a PHP file consisting only of <? phpinfo(); ?> (short tags enabled in php.ini).

Created a small test.php file consisting only of HTML (open and close HTML tags, and 512 bytes of data).  Problem occurs ~20-30% of the time.  Interestingly enough, I noticed that if I refresh the test.php page quickly enough, I get back an HTTP 403.9: "The page cannot be displayed.  There are too many people accessing the Web site at this time."  I've never received that error before under any other condition.  In actuality, when this occurs, the number of times I'd refreshed the page is really pretty low (five or six), and the refreshes aren't done all that fast, relatively speaking.
 [2007-12-04 12:40 UTC] webmaster at cosmicperl dot com
!!SOLUTION!!
!!SOLUTION!!

If you download the latest PHP - MySQL connector files direct from MySQL this problem goes away:-

http://dev.mysql.com/downloads/connector/php/


Why hasn't PHP updated to these latest files?!?!?

!!SOLUTION!!
!!SOLUTION!!
 [2007-12-05 12:53 UTC] ulmer at energieagentur dot nrw dot de
The version of the mysql extension at http://dev.mysql.com/downloads/connector/php/ is 5.0.27 right now which seems to be quite old. The Changelog date is 2006-11-17, so it is more than a year old!

Installing this version is NOT a solution for me.
 [2007-12-07 13:47 UTC] jean-yves dot deleze at crealp dot vs dot ch
I recently installed PHP 5.2.5 on Windows and the error was still there (MySQL version 5.0.45). The only way to remove the error was to use old versions of php_mysql(i).dll or libmysql.dll (<= 5.0.27).

Today I downloaded MySQL 5.0.51 Win32 sources, I compiled the libmysql.dll library and replaced the one shiped with PHP 5.2.5. This solved the problem.
 [2007-12-10 16:21 UTC] m dot bariola at prodigiweb dot it
Hi,

I experienced this problem too and still am. however I might give some info that might move the focus to a different point. Reading the comments, I see that some people are experiencing it with or without mySQL, or on imap, solving with older lib version, etc.

I have two winXP systems both running the same XAMPP version (1.6.4). I have no problems on my home PC, so I repeated the configuration on the work PC. easy as repeating the XAMPP installation with same paths as home, then copying the apache conf folder from home, and modifying the Path variable so that it will look for executables in c:\xampp\php also.

basically, exactly the same as home, but the work PC does not work, while the home installation has no such problems.

hope this helps in finding the real cause of the problem.
 [2007-12-17 10:44 UTC] scratch65535 at att dot net
I'm in the throes of converting from PHP 4 and MySQL 4 to PHP 5.2.5 and MySQL 5.0.45 on my W2K dev machine.  So I'm moving to latest-and-greatest code on both sides, and was quite surprised, also dismayed, to see this my_thread bug.
 [2007-12-21 02:46 UTC] ekarudito at gmail dot com
i have error too...
using apache 2.2.4
php 5.2.1 (windows XP)
mysql 5.0.37

i have this error when using stored procedure.. in php script
and show this error in error log in apache..

and i think's maybe.. caused by bind_result function.. (using mysqli)

because when i comment this function, mozzila can work normally 
although it show few of warning ....
 [2007-12-23 18:57 UTC] cappytoi at yahoo dot com
Replacing the php5.2.1/libmysql.dll is fixed my problem with ISS 6 with ISAPI on Win2003.

http://www.it-etc.com/wp-content/uploads/2007/10/php_520_libmysqldll_win32.zip
 [2007-12-28 07:46 UTC] jungno at gmail dot com
i had the same bug
Error in my_thread_global_end(): 3 threads didn't exit 

I replaced old libmysql.dll file with the new file from the file php_5.2.0_mysql_5.0.27-win32.zip

my file with the bad libmysql.dll file was from the file php-5.2.5-win32-installer.msi

running IIS5.1 on winxp2 and php5.2.5
 [2008-01-03 16:18 UTC] stalin dot gsk at gmail dot com
Include($header) and function fputs($csvf, "string") not detecting by PHP 5.2.3
Iam using WIN NT server with IIS 6


Error msg:
Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.;./includes;./pear') in C:\Inetpub\vhosts\shopinonline.co.in\cgi-bin\checkout.php on line 61


Iam adding the code below plz check if any thing can be done to make it work advanced thanks for those who can try helping me site was launched and this shopping is making plz help soon.

PHP code:

checkout.php
<?
//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                   PHP SCRIPT Checkout Module                        ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||
//                                                                     ||
//  Function: Writes available form elements from the NOP              ||
//            Free Cart (http://www.nopdesign.com/freecart)            ||
//            and other form elements to an email file, and            ||
//            send user confirmation                                   ||
//                                                                     ||
//=====================================================================||


//######################################################################
//                                                                     #
// User defined variables:                                             #
//     $header        - string value containing the complete           #
//                      path of the HTML page header                   #
//     $footer        - string value containing the complete           #
//                      path of the HTML page footer                   #
//     $youremail     - string value containing the email address to   #
//                      send catalog orders in EMAIL or BOTH modes     #
//     $returnpage    - URL to send user when checkout is complete     #
//     $csvfilename   - string value containing the complete           #
//                      path of the user database.                     #
//     $csvquote      - string value containing what to use for quotes #
//                      in the csv file (typically "" or \")           #
//     $mode          - string value containing 'EMAIL', 'FILE' or     #
//                      'BOTH' to determine if the script should send  #
//                      an email to you with the new order, write the  #
//                      order to a CSV file, or do both.               #
//######################################################################
$header        = "header.html";
$footer        = "footer.html";
$returnpage    = "thankyou.html";
$youremail     = "support@shopinonline.co.in";
$csvfilename   = "orders.csv";
$csvquote      = "\"\"";
$mode          = "BOTH";


//##############################################################
//#FUNCTION:   doFormError                                     #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating a form        #
//#            submission error occurred.                      #
//##############################################################
function doFormError($errString) {

    include($header);

    echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
    echo "$errString<BR><BR>\n";
    echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE='  Return to the checkout page '><HR>";

    include($footer);

    exit;
}

//##############################################################
//#FUNCTION:   doError                                         #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating an error      #
//#            occurred.                                       #
//##############################################################
function doError($errString) {

    include($header);

    echo "$errString<BR><BR>\n";

    include($footer);

    exit;
}



//##############################################################
//##############################################################
//###  MAIN                                                  ###
//##############################################################
//##############################################################

if (($b_conf == "") || ($b_first == "") || ($b_last == "") || ($b_addr == "") || ($b_city == "") || ($b_state == "") || ($b_zip == "") || ($b_phone == "") || ($b_email == "")) {
   doFormError("I'm sorry, but it appears that you forgot to fill in a required field.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
   exit;
}

//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$b_email)) ) {
    doFormError("You submitted an invalid email address.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
    exit;
}

$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "A new order has been received.  A summary of this order appears below.\n";
$strMessageBody .= "\n";
$strMessageBody .= "Order Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Bill To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $b_first $b_last \n";
$strMessageBody .= "   $b_addr \n";
$strMessageBody .= "   $b_addr2 \n";
$strMessageBody .= "   $b_city, $b_state  $b_zip \n";
$strMessageBody .= "   $b_phone \n";
$strMessageBody .= "   $b_fax \n";
$strMessageBody .= "   $b_email \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Ship To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $s_first $s_last \n";
$strMessageBody .= "   $s_addr \n";
$strMessageBody .= "   $s_addr2 \n";
$strMessageBody .= "   $s_city, $s_state  $s_zip \n";
$strMessageBody .= "   $s_phone \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qty  Price(\$)   Product ID  - Product Name\n";
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "$QUANTITY_1    \$$PRICE_1    $ID_1 - $NAME_1   $ADDTLINFO_1  \n";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2    \$$PRICE_2    $ID_2 - $NAME_2   $ADDTLINFO_2  \n";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3    \$$PRICE_3    $ID_3 - $NAME_3   $ADDTLINFO_3  \n";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4    \$$PRICE_4    $ID_4 - $NAME_4   $ADDTLINFO_4  \n";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5    \$$PRICE_5    $ID_5 - $NAME_5   $ADDTLINFO_5  \n";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6    \$$PRICE_6    $ID_6 - $NAME_6   $ADDTLINFO_6  \n";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7    \$$PRICE_7    $ID_7 - $NAME_7   $ADDTLINFO_7  \n";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8    \$$PRICE_8    $ID_8 - $NAME_8   $ADDTLINFO_8  \n";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9    \$$PRICE_9    $ID_9 - $NAME_9   $ADDTLINFO_9  \n";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10    \$$PRICE_10    $ID_10 - $NAME_10   $ADDTLINFO_10 \n";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11    \$$PRICE_11    $ID_11 - $NAME_11   $ADDTLINFO_11 \n";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12    \$$PRICE_12    $ID_12 - $NAME_12   $ADDTLINFO_12 \n";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13    \$$PRICE_13    $ID_13 - $NAME_13   $ADDTLINFO_13 \n";}
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "SUBTOTAL: $SUBTOTAL \n";
$strMessageBody .= "TOTAL: $TOTAL \n";
$strMessageBody .= "\n";
$strMessageBody .= "FREIGHT: $SHIPPING \n";
$strMessageBody .= "\n\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "--------- \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";


if( $mode == "BOTH" || $mode == "EMAIL") {
   //# Send email order to you...
   $mailheaders = "From: $b_email\r\n";
   $mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
   $subject = "New Online Order";
   mail($youremail, $subject, $strMessageBody, $mailheaders);
}


if( $mode == "BOTH" || $mode == "FILE") {
   
   $csvcomments = $comment;
   if (!$CSVF = fopen($csvfilename,'a')) {
       doError("Unable to open CSV file for writing.  Your order has not been saved.");
       exit;
   }

   fputs($CSVF, $string);
   fputs($CSVF, "\"");
   fputs($CSVF, "$today");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_conf");
   fputs($CSVF, "\",\"");

   fputs($CSVF, "$b_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_phone");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_fax");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_email");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_phone");
   fputs($CSVF, "\",\"");   
   fputs($CSVF, "$QUANTITY_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SUBTOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$TOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SHIPPING");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$comment");
   fputs($CSVF, "\"\n");
   
   fclose($CSVF);
}

//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
$subject = "Order Confirmation";
mail($b_email, $subject, $strMessageBody, $mailheaders);

include($header);

echo "<h2>Thank you</h2>";
echo "Thank you for your order from our online store.  You will receive a confirmation email of your order ";
echo "momentarily.  Please contact us at $youremail if you have any questions or concerns.";
echo "<P>";
echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";

include($footer);

?>
 [2008-01-03 16:18 UTC] stalin dot gsk at gmail dot com
Include($header) and function fputs($csvf, "string") not detecting by PHP 5.2.3
Iam using WIN NT server with IIS 6


Error msg:
Warning: include() [function.include]: Failed opening '' for inclusion (include_path='.;./includes;./pear') in C:\Inetpub\vhosts\shopinonline.co.in\cgi-bin\checkout.php on line 61


Iam adding the code below plz check if any thing can be done to make it work advanced thanks for those who can try helping me site was launched and this shopping is making plz help soon.

PHP code:

checkout.php
<?
//=====================================================================||
//               NOP Design JavaScript Shopping Cart                   ||
//                   PHP SCRIPT Checkout Module                        ||
//                                                                     ||
// For more information on SmartSystems, or how NOPDesign can help you ||
// Please visit us on the WWW at http://www.nopdesign.com              ||
//                                                                     ||
// Javascript portions of this shopping cart software are available as ||
// freeware from NOP Design.  You must keep this comment unchanged in  ||
// your code.  For more information contact FreeCart@NopDesign.com.    ||
//                                                                     ||
// JavaScript Shop Module, V.4.4.0                                     ||
//=====================================================================||
//                                                                     ||
//  Function: Writes available form elements from the NOP              ||
//            Free Cart (http://www.nopdesign.com/freecart)            ||
//            and other form elements to an email file, and            ||
//            send user confirmation                                   ||
//                                                                     ||
//=====================================================================||


//######################################################################
//                                                                     #
// User defined variables:                                             #
//     $header        - string value containing the complete           #
//                      path of the HTML page header                   #
//     $footer        - string value containing the complete           #
//                      path of the HTML page footer                   #
//     $youremail     - string value containing the email address to   #
//                      send catalog orders in EMAIL or BOTH modes     #
//     $returnpage    - URL to send user when checkout is complete     #
//     $csvfilename   - string value containing the complete           #
//                      path of the user database.                     #
//     $csvquote      - string value containing what to use for quotes #
//                      in the csv file (typically "" or \")           #
//     $mode          - string value containing 'EMAIL', 'FILE' or     #
//                      'BOTH' to determine if the script should send  #
//                      an email to you with the new order, write the  #
//                      order to a CSV file, or do both.               #
//######################################################################
$header        = "header.html";
$footer        = "footer.html";
$returnpage    = "thankyou.html";
$youremail     = "support@shopinonline.co.in";
$csvfilename   = "orders.csv";
$csvquote      = "\"\"";
$mode          = "BOTH";


//##############################################################
//#FUNCTION:   doFormError                                     #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating a form        #
//#            submission error occurred.                      #
//##############################################################
function doFormError($errString) {

    include($header);

    echo "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
    echo "$errString<BR><BR>\n";
    echo "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE='  Return to the checkout page '><HR>";

    include($footer);

    exit;
}

//##############################################################
//#FUNCTION:   doError                                         #
//#RETURNS:                                                    #
//#PARAMETERS: A error message string.                         #
//#PURPOSE:    Generates an HTML page indicating an error      #
//#            occurred.                                       #
//##############################################################
function doError($errString) {

    include($header);

    echo "$errString<BR><BR>\n";

    include($footer);

    exit;
}



//##############################################################
//##############################################################
//###  MAIN                                                  ###
//##############################################################
//##############################################################

if (($b_conf == "") || ($b_first == "") || ($b_last == "") || ($b_addr == "") || ($b_city == "") || ($b_state == "") || ($b_zip == "") || ($b_phone == "") || ($b_email == "")) {
   doFormError("I'm sorry, but it appears that you forgot to fill in a required field.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
   exit;
}

//# checks for valid email address
if( !(ereg("^(.+)@(.+)\\.(.+)$",$b_email)) ) {
    doFormError("You submitted an invalid email address.  Please go <A HREF='Javascript:history.go(-1);'>back</A> and correct the error.");
    exit;
}

$today = date ("l, F jS Y");
$strMessageBody = "";
$strMessageBody .= "A new order has been received.  A summary of this order appears below.\n";
$strMessageBody .= "\n";
$strMessageBody .= "Order Date: $today \n";
$strMessageBody .= " \n";
$strMessageBody .= "Bill To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $b_first $b_last \n";
$strMessageBody .= "   $b_addr \n";
$strMessageBody .= "   $b_addr2 \n";
$strMessageBody .= "   $b_city, $b_state  $b_zip \n";
$strMessageBody .= "   $b_phone \n";
$strMessageBody .= "   $b_fax \n";
$strMessageBody .= "   $b_email \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Ship To: \n";
$strMessageBody .= "-------- \n";
$strMessageBody .= "   $s_first $s_last \n";
$strMessageBody .= "   $s_addr \n";
$strMessageBody .= "   $s_addr2 \n";
$strMessageBody .= "   $s_city, $s_state  $s_zip \n";
$strMessageBody .= "   $s_phone \n";
$strMessageBody .= " \n";
$strMessageBody .= " \n";
$strMessageBody .= "Qty  Price(\$)   Product ID  - Product Name\n";
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "$QUANTITY_1    \$$PRICE_1    $ID_1 - $NAME_1   $ADDTLINFO_1  \n";
if( $NAME_2 ) {$strMessageBody .= "$QUANTITY_2    \$$PRICE_2    $ID_2 - $NAME_2   $ADDTLINFO_2  \n";}
if( $NAME_3 ) {$strMessageBody .= "$QUANTITY_3    \$$PRICE_3    $ID_3 - $NAME_3   $ADDTLINFO_3  \n";}
if( $NAME_4 ) {$strMessageBody .= "$QUANTITY_4    \$$PRICE_4    $ID_4 - $NAME_4   $ADDTLINFO_4  \n";}
if( $NAME_5 ) {$strMessageBody .= "$QUANTITY_5    \$$PRICE_5    $ID_5 - $NAME_5   $ADDTLINFO_5  \n";}
if( $NAME_6 ) {$strMessageBody .= "$QUANTITY_6    \$$PRICE_6    $ID_6 - $NAME_6   $ADDTLINFO_6  \n";}
if( $NAME_7 ) {$strMessageBody .= "$QUANTITY_7    \$$PRICE_7    $ID_7 - $NAME_7   $ADDTLINFO_7  \n";}
if( $NAME_8 ) {$strMessageBody .= "$QUANTITY_8    \$$PRICE_8    $ID_8 - $NAME_8   $ADDTLINFO_8  \n";}
if( $NAME_9 ) {$strMessageBody .= "$QUANTITY_9    \$$PRICE_9    $ID_9 - $NAME_9   $ADDTLINFO_9  \n";}
if( $NAME_10 ){$strMessageBody .= "$QUANTITY_10    \$$PRICE_10    $ID_10 - $NAME_10   $ADDTLINFO_10 \n";}
if( $NAME_11 ){$strMessageBody .= "$QUANTITY_11    \$$PRICE_11    $ID_11 - $NAME_11   $ADDTLINFO_11 \n";}
if( $NAME_12 ){$strMessageBody .= "$QUANTITY_12    \$$PRICE_12    $ID_12 - $NAME_12   $ADDTLINFO_12 \n";}
if( $NAME_13 ){$strMessageBody .= "$QUANTITY_13    \$$PRICE_13    $ID_13 - $NAME_13   $ADDTLINFO_13 \n";}
$strMessageBody .= "===================================================================== \n";
$strMessageBody .= "SUBTOTAL: $SUBTOTAL \n";
$strMessageBody .= "TOTAL: $TOTAL \n";
$strMessageBody .= "\n";
$strMessageBody .= "FREIGHT: $SHIPPING \n";
$strMessageBody .= "\n\n";
$strMessageBody .= "Comments: \n";
$strMessageBody .= "--------- \n";
$strMessageBody .= "$comment \n";
$strMessageBody .= " \n";


if( $mode == "BOTH" || $mode == "EMAIL") {
   //# Send email order to you...
   $mailheaders = "From: $b_email\r\n";
   $mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
   $subject = "New Online Order";
   mail($youremail, $subject, $strMessageBody, $mailheaders);
}


if( $mode == "BOTH" || $mode == "FILE") {
   
   $csvcomments = $comment;
   if (!$CSVF = fopen($csvfilename,'a')) {
       doError("Unable to open CSV file for writing.  Your order has not been saved.");
       exit;
   }

   fputs($CSVF, $string);
   fputs($CSVF, "\"");
   fputs($CSVF, "$today");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_conf");
   fputs($CSVF, "\",\"");

   fputs($CSVF, "$b_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_phone");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_fax");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$b_email");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_first");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_last");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_addr2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_city");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_state");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_zip");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$s_phone");
   fputs($CSVF, "\",\"");   
   fputs($CSVF, "$QUANTITY_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_1");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_2");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_3");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_4");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_5");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_6");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_7");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_8");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_9");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_10");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_11");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_12");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$QUANTITY_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "\$$PRICE_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ID_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$NAME_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$ADDTLINFO_13");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SUBTOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$TOTAL");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$SHIPPING");
   fputs($CSVF, "\",\"");
   fputs($CSVF, "$comment");
   fputs($CSVF, "\"\n");
   
   fclose($CSVF);
}

//# Send email conformation to the customer.....
$mailheaders = "From: $youremail\r\n";
$mailheaders .="X-Mailer: PHP Mail generated by:NOP Design Shopping Cart\r\n";
$subject = "Order Confirmation";
mail($b_email, $subject, $strMessageBody, $mailheaders);

include($header);

echo "<h2>Thank you</h2>";
echo "Thank you for your order from our online store.  You will receive a confirmation email of your order ";
echo "momentarily.  Please contact us at $youremail if you have any questions or concerns.";
echo "<P>";
echo "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
echo "<P>";

include($footer);

?>
 [2008-01-04 11:54 UTC] benjamin dot azan at gmail dot com
The mySQL bug http://bugs.mysql.com/bug.php?id=25621 says :

" MySQL 5.0.54BK on WinXP localhost does not exhibit the error. "

and the PHP 5.2.5 show Client API version 	5.0.45

So I think the next version of PHP should contain this new version of the MySQL connector.

I'm gonna try to upgrade the mySQL connector on a 5.2.5 PHP version to see if it fixs the bug
 [2008-01-04 14:30 UTC] benjamin dot azan at gmail dot com
I could not find the new version of mysql connector but I changed the PHP mode from CGI/fastCGI to  Apache 2.0 Handler and it fixed the problem.
 [2008-01-04 18:28 UTC] jcmelcher at gmail dot com
This worked for me... IIS 6.0 with PHP 5.2.5 on Win2K3 SP2

If you download the latest PHP - MySQL connector files direct from MySQL
this problem goes away:-

http://dev.mysql.com/downloads/connector/php/
 [2008-01-04 21:44 UTC] jaco at jump dot co dot za
I am having the same and more problems. 

I am running:

Apache 2.2.6
MySQL 5.0.45
PHP 5.2.5
Windows Server 2003 R2 Standard SP2

2 x Quad Core Xeon
4Gb RAM

IIS Installed for SMTP, FTP and WWW on port 443 for a single .NET Webservice access (NO PHP connectors installed for IIS). But I am sure this is not IIS related, becuase it still happens even with IIS stopped



Whenever apache tries to recycle threads I get:

** Apache Error Log **

[Fri Jan 04 22:37:38 2008] [notice] Child 324: All worker threads have exited.
Error in my_thread_global_end(): 1 threads didn't exit
exiting because it reached MaxRequestsPerChild. Signaling the parent to restart a new child process.
[Fri Jan 04 22:37:42 2008] [notice] Parent: Received restart signal -- Restarting the server.

************************

Note the time difference between the first log and the last log

This then causes my Apache to crash and restart.

Then I tried to download the latest snapshot of PHP, installed it, but then Apache woould not start at all, just gives me a starting status, but does not het out of it.

My problem is also that there is hundreds of php files running and our site is very active, and I have NO idea what is causing this problem. The PHP error log is clean, but the following also shows up AFTER apache crashes.

080104 11:24:26 [Warning] Aborted connection 16865 to db: '********' user: '*****' host: 'localhost' (Got an error reading communication packets)

But I am sure that this is just caused by apache that have crashed and the already open calls to the database that was not terminated by the php script.


These messages apears in the event log after the crash:

Faulting application httpd.exe, version 2.2.6.0, faulting module libapr-1.dll, version 1.2.11.0, fault address 0x000079a0.

Faulting application httpd.exe, version 2.2.6.0, faulting module php5ts.dll, version 5.2.5.5, fault address 0x0000acb9.

We are using both mysql and mysqli connectors and I have tried to download the ones from the mysql site and again apache refused to start. 

This is quite serious for us at the moment, becuase its in a live enviroment and the dev servers never had this problem. 

Hope we can find a solution soon.
 [2008-01-07 12:14 UTC] jaco at jump dot co dot za
I was able to reproduce this on a very basic instalation:

Apache 2.2.4
PHP 5.2.5
Windows 2003 Server
NO Database installed

<?
$fp = fsockopen("192.168.1.105", 3312);
fclose($fp)
echo "DONE";
exit;
?>

This executes 100%, and gives no errors, but as soon as I stop apache, it gives me the message in the apache error log

Error in my_thread_global_end(): 1 threads didn't exit

So it seems to me more of a sockets problem than a mysql problem.

When I run the same script in CLI, I get no error.
 [2008-01-10 17:49 UTC] amoo_miki at yahoo dot com
This is caused by windows security:

to be sure:
1) Check if the drive where PHP is installed is an NTFS partition.
2) If yes, "Read & Execute" for "Everyone" for the "ext" folder.

php -v at the command-line should not show you the error anymore.
 [2008-01-11 21:39 UTC] jmair at parkcountyre2 dot org
IIS 6 on Windows 2003 server fully patched. php 5.2.5 mysql 

This issue was killing me for a week. I tried every successful attempt from previous posts and no resolve.

I was also getting this problem with no mysql.

I downloaded and installed fastcgi and followed the manual install for fastcgi and php, not only is the Php not displaying the error, but it's running faster than I've ever seen, maybe almost as fast as a linux box =0

hope this helps somebody.

here is the link.
http://www.iis.net/articles/view.aspx/IIS7/Hosting-Web-Applications/PHP/Using-FastCGI-to-Host-PHP-Applications-on-IIS-6-0-?Page=2
 [2008-01-22 20:30 UTC] codeslinger at compsalot dot com
Ping,
Can we get php updated please?  This problem is now one year old.

Everyone who updates to the latest Windows php = 5.2.5 encounters this bug, it results in total breakage of loading the mysql dll.

This bug has cost thousands upon thousands of man-hours to be expended/wasted by site admins in trying to locate the cause of the problem and the fix for it.  In some cases it has also caused people to abandon the use of php-mysql programs altogether.

According to MySQL Bug: http://bugs.mysql.com/bug.php?id=25621

The final resolution is that the problem was with mysql not php and that the problem was fixed awhile ago, and that all that is needed is for php to update to the latest mysql library.

Given the fundamental importance of the php mysql interface, as in LAMP, it is inexplicable that it has taken an entire year to resolve what appears to have been a fairly simple fix.
 [2008-02-07 22:27 UTC] WS6TA at txlanes dot com
I have to agree about the impression this makes on potential LAMP adopters.  I am a long-time Windows/MSSQL person looking at the LAMP stack as an alternative to MS.  However, I download PHP 5.2.5 and start reading the manual only to get the error "Error in my_thread_global_end()" the first time I used the CLI.  So, I go searching and find all kinds of references to dll swaps for PHP side AND the MySQL side.  I don't even have MySQL installed yet...  I was looking at PHP's ability to be a standalone scripting tool as well as a web-database tool.

Anyway, I then find this thread where it appears the bug has been around since approximately May 2007 and PHP version 5.2.3.  I commented out "extension=php_mysql.dll" in the php.ini to stop the error, but I think I will want this extension once I install MySQL.

My hat's off to the people that started and have contributed to the PHP codebase.  Please understand that I am not trying to bash anyone.  I simply want to reiterate the PHP is crucial component to the LAMP stack and having to search for a bug fix on the very first run discourages potential new adopters.  I'm very impressed with what I know about PHP thus far and would hate to think a potential  adopter could be discouraged at square one in their evaluation.
 [2008-02-08 06:56 UTC] OPunWide at hotmail dot com
I'm a newbie at this, and am installing php for the first time. Very basic setup, running WinXP, using IIS 5.1 and PHP 5.2.5, installed using the Windows installer. 

When I first installed I included support for MySQL in the options, but had not installed MySQL. The error happened with a psp script consisting only of pspinfo(). I went back to the installer and removed support for MySQL and the problem went away.

I don't think the folks at MySQL can be blamed for this one.
 [2008-02-13 17:25 UTC] byerly0503 at gmail dot com
This bug caused me to spend an hour on the issue.  I kept ignoring all of the help related to MySQL since the script I was trying to run, didn't use MySQL.  

Please fix this by including the right DLL or adjust the installer to give a warning message:  "Despite downloading this package, you will need to download an older package, replace the mysql dll, in order to use PHP."
 [2008-02-20 17:05 UTC] brandonkahre at charter dot net
I am still experiencing this bug as of Feb-20-2008.  I am running PHP 5.2.4 in a Windows XP environment with MySQL 4.2.20.  To leave no room for confusion, the problems and steps I am using to recreate this bug are described in Bug #44009 (http://bugs.php.net/bug.php?id=44009).

I have tried the following PHP versions:
PHP 5.2.4
PHP 5.2.5
PHP 5.2.6-latest

I have tried patching the Windows php_mysql.dll extension using the following sources:
PHP 5.2.1: http://www.php.net/releases/#5.2.1 [copy /ext/php_mysql.dll only] - this did not fix any problems
MySQL: http://dev.mysql.com/downloads/connector/php/ [mysql extension (PHP 5.2.0) for MySQL Server 4.1.21] - could not connect to MySQL server.  Please note that the extension is for PHP 5.1.6.6
MySQL: http://dev.mysql.com/downloads/connector/php/ [mysql extension (PHP 5.2.0) for MySQL Server 5.0.27] - this did not fix any problems
IT-Guys (mentioned in this bug tracker): http://www.it-etc.com/2007/10/25/php-error-524-getting-error-error-in-my_thread_global_end-1-threads-didnt-exit/ - this did not fix any problems.  The extensions provided seem to be for PHP 5.2.0.0
 [2008-02-25 20:50 UTC] sharadrb at yahoo dot com
Even I had same issue with PHP version 5.2.5. So, I rolled back to older version 5.2.1 which does not have this issue. Now, I don't have this issue with version 5.2.1
 [2008-03-12 18:42 UTC] emiller at rsimedical dot com
Experiencing Issue on  Win2k3, Apache 2.2.8, PHP 5.2.4

Apache hangs, on Apache service stop error appears in error.log
 [2008-03-13 11:16 UTC] email at email dot com
I also solved this issue with copying the libmysql.dll file from the previous version. 

Downloaded libmysql.dll file from http://mysql.oblique.ch/ (it is a previous version file), copied it over the current one (C:/PHP/libmysql.dll). 
 
This solved the issue.
 [2008-03-18 22:37 UTC] stein at visibone dot com
I'm still having a 5 second delay at the end of my command-line invocation.  Putting 5.0.51a libmysql.dll in C:\Program Files\PHP seemed to eliminate the my_thread_global_end() error, and replacing ext\php_mysql.dll and ext\php_mysqli.dll stopped the 5-second delay when running a simple "php --ini" or hello-world script.  But I still get a 5 second delay if I call mysql_connect() & mysql_close().

php -i (phpinfo) excerpts:
   mysql
   Client API version => 5.0.51a
   mysqli
   Client API library version => mysqlnd 5.0.1-beta - 070402 - $Revision: 321 $

Help would sure be appreciated.  5 seconds x 1000 hurts.

-- Bob Stein, VisiBone
 [2008-03-19 18:39 UTC] stein at visibone dot com
...addendum to previous, the php_mysql.dll and php_mysqli.dll I installed were from PHP 5.2.1 zip file.
 [2008-03-20 19:39 UTC] stein at visibone dot com
...free PHP cheatsheet or wall chart to anyone who helps me get around this.  ;-)
 [2008-03-20 20:05 UTC] scottmac@php.net
Try PHP 5.2.5 with the libmysql.dll from http://dev.mysql.com/downloads/mysql/5.0.html#win32

Make sure there are no other libmysql.dll lurking around your path.
 [2008-03-22 22:01 UTC] lizwatson02452 at yahoo dot com
I have this problem, and I am *not* using MySQL. I'm on PHP 5.2.4, with SQL Server. Are there any workarounds that are not MySQL-specific?
 [2008-03-26 20:56 UTC] lizwatson02452 at yahoo dot com
Following up briefly on my previous post....changing to an earlier libmysql.dll appears to have fixed the problem for us, even though we don't use MySQL.

Two difficulties with that:
 1) It was hard for me to believe that was the solution.
 2) It took some doing to persuade our hoster that changing the .dll was not merely a fool's errand.
 [2008-03-28 22:23 UTC] stein at visibone dot com
Brilliant, Scottmac, I did have some crufty lurking libmysql.dll's.  But I'm still getting the 5 second hang.  Using the 5.2.5 php_mysql.dll and php_mysqli.dll's the hang happens with a dirt-simple hello-world.  With 5.2.1 it happens if I mysql_connect().

Could it be having both mysql and mysqli enabled?  I'm using both for unit testing.  

-- Bob Stein, VisiBone
 [2008-04-08 20:14 UTC] spambox at shad dot pp dot ru
Same bug just happened to me in this example:

C:\>echo "<?php echo date('T'); ?>" |php
"MSD"
Error in my_thread_global_end(): 1 threads didn't exit

MySQL extension was enabled in php.ini, but I didn't use any of it's functions in example. PHP is 5.2.5, no other mysql related dll's are available on system.

I posted this just to confirm that bug exists on my system too.
 [2008-04-09 15:16 UTC] jdolecek at NetBSD dot org
Downgrading BOTH libmysql.dll AND php_mysql.dll to version bundled with PHP 5.2.1 fixed the issue for me, too.
 [2008-04-16 04:12 UTC] tristen_e at yahoo dot com
This is still a problem:

$ php --version
PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
 [2008-04-22 14:01 UTC] newcomer at hotmail dot com
We just upgraded to PHP Version 5.2.5. the "Error in my_thread_global_end(): 1 threads didn't exit" appeared no matter the application uses MySQL or not. Replaced the libmysql.dll from V.5.0.45, the error disappear. But the application is running very slow. Switched back to PHP version4. Everything back to normal.
 [2008-04-27 13:59 UTC] alienoiduk at yahoo dot com
You need to install MySQL5.051a for linux and MySQL 5.0.5b1 for windows. If installed the wrong way around there will be a delay in executing. 
Also copy the correct libmysql.dll to the C:\PHP\ folder I installed MySQL 5.0.51b at C:\Mysql\ therfor the libmysql.dll file you require will be in folder C:\MySQL\lib\opt  the file is the Application Extension file size of about 2,000K.

This worked on a brand new server running IIS6 windows 2003 server latest download from PHP 5.2.5 and MySQL 5.0.51b did as above no errors no hangup or delays. I am not run MySQLi.
 [2008-05-06 14:52 UTC] newcomer at hotmail dot com
to alienoiduk:

What kind of the application do you run under PHP&MySQL? we are running a wordpress blog. it was doing fine with the old version php (5.0 or older).When we upgraded php to 5.2.5, the blog got the error message. Then I replaced the libmysql.dll from php v.5.0.51, the error message disappear, but the blog runs very slow. it is so slow we have to switch php back to the old version. 

anyone has this experience with wordpress?
 [2008-05-09 15:10 UTC] chris at crgs dot co dot uk
Just upgraded to PHP 5.2.6. As others have experienced, the error message is gone, but there is still an unacceptable 5 second delay at the end of loading every page, whether or not it accesses the MySQL database or not.

Downgrading to libmysql.dll from PHP 5.2.1 fixed the problem, as always.
 [2008-05-26 20:16 UTC] jani@php.net
Still not properly fixed.
 [2008-05-26 20:36 UTC] jani@php.net
Fixeth or not, that's the question? Assigning to The One who should know..
 [2008-05-29 23:06 UTC] jani@php.net
See bug #44078 for possible solution.
 [2008-05-30 04:04 UTC] louis at steelbytes dot com
still got slowness on exit with php 5.2.6 when using mysql AND CURL (As somebody else noted in bug #41968 that was marked as a dupe of this bug)

and still replacing libmysql.dll with the copy from php 5.2.1 fixes it.

doesn't seem to be happending to me when only using mysql and not curl?

PS, am using dl() to load these two extension - not php.ini
 [2008-05-31 03:00 UTC] da_pimp2004_966 at hotmail dot com
Ok, I used the updated versions of the files and I recieved this error;

PHP Warning: PHP Startup: mysql: Unable to initialize module Module compiled with module API=20060613, debug=0, thread-safety=1 PHP compiled with module API=20060613, debug=0, thread-safety=0 These options need to match in Unknown on line 0 

Anybody have any ideas?

da_pimp2004_966@hotmail.com - any help appreciated.
 [2008-06-04 16:58 UTC] onehourlate at hotmail dot com
php 5.2.6, Windows Visa or XP
I confirm that the 5 seconds delay on exit is still there.

Grabbing libmysql.dll from the lastest stable Mysql (5.0.51b) didn't help. Haven't tried to use binaries from php 5.2.1 yet.

The problem seems to appear as soon as I play with sockets.

<?
$fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
if (!$fp) {
  echo "ERROR: $errstr ($errno)\n";
} else {
  echo "OK\n";
  fclose($fp);
}
?>
 [2008-06-06 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2008-06-09 02:33 UTC] kneekoo at yahoo dot com
As indicated in some of the above messages, I tried some advices but nothing changed on my setup.

1. Commenting
;[PHP_MYSQL]
;extension=php_mysql.dll

and de-commenting
extension=php_mysql.dll

didn't help.

2. Switching mysql.allow_persistent to Off didn't help as well.

I downloaded PHP 5.2.6, installed it on a WinXP SP2 system and that's it. There is a delay (more than 5 seconds to me - about 7) and this message:

Error in my_thread_global_end(): 1 threads didn't exit

It's shocking to find out there isn't an official fix for this after one whole year. Lucky me I can work with my scripts but I hope this won't interfere with my development further on. Please, guys, fix this. Thanks!
 [2008-06-09 10:12 UTC] Computer dot Pers at gmail dot com
So... Is there's any solution???

C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>php -v
PHP 5.2.5 (cli) (built: Nov  8 2007 23:18:51)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
Error in my_thread_global_end(): 1 threads didn't exit
 [2008-06-09 10:55 UTC] scottmac@php.net
First you need 5.2.6 and secondly you need to check for old libmysql.dll files lurking around in your path, I can't reproduce this with MySQL 5.0.51.

Can you reproduce this when you disable all extensions and just enable MySQL? If you start enabling extensions which one causes the problem?

On phpinfo() what version of libmysql does it show?

If you don't have PHP 5.2.6 and MySQL 5.0.51 or newer then please upgrade before you consider replying.
 [2008-06-09 11:47 UTC] Computer dot Pers at gmail dot com
OK.
I've upgraded PHP to latest 5.2.6
Message: "Error in my_thread_global_end(): 1 threads didn't exit"
is disappeared.

but delay of 5 seconds is here.
I've disabled ALL plugins and there's no any delay.
1. Then i've enabled "extension=php_mysql.dll"
2. i've created script, which shows curent time before and after "php -v" commnad and launched it several times
here is result:

1. No delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:16
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:16

2. Delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:18
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:23

3. No delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:26
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:26

4. No delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:28
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:28

5. No delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:29
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:29

6. No delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:30
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:30

7. Delay
C:\Program Files\SWsoft\Plesk\Additional\PleskPHP5>phpinfo.bat
09.06.2008 14:33:31
PHP 5.2.6 (cli) (built: May  2 2008 18:02:07)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
09.06.2008 14:33:36

.........
1 of 3 or 4 times i see a delay of 5 secs.
and this is on a machine Intel Xeon E5335 @2Ghz 4Gb Ram at Idle state

MySql for test reason was STOPPED.
 [2008-06-11 21:20 UTC] paul at orac dot clara dot co dot uk
Brand new install of Win XP, with IIS (5.1).
Installed PHP 5.2.6 (IIS set to use PHP in CGI mode not ISAPI).
MySQL is NOT installed on the machine.
The only version of libmysql.dll anywhere is the one supplied with php (version 5.00.51a).

With either or both of "extension=php_mysql.dll" or "extension=php_mysqli.dll" enabled, running "php-cgi -v" results in the 5 second delay about 25% of the time (5 times out of 20 - very repeatable).
The same happens running a browser to a local web page containing just a call to phpinfo().
With both the extension lines commented, the problem does not occur, ever.
Running "php -v" I never see the problem occur, ever, even with the extensions enabled.

Replacing libmysql.dll with the one from php 5.2.1 (version 5.00.22)
causes the above 5 second delay to disappear in ALL cases.

The first version of libmysql.dll that caused the problem was that supplied with php 5.2.2.

Surely it can't be too hard to start back with those two versions and work out what changed between them?
 [2008-06-11 21:33 UTC] paul at orac dot clara dot co dot uk
At last, someone seems to have a clue:
  http://bugs.mysql.com/bug.php?id=25621
  http://bugs.mysql.com/bug.php?id=37226
 [2008-06-12 08:44 UTC] scottmac@php.net
This was a change by MySQL, not by PHP. We simply bundle the latest version of MySQL, if you use PHP 5.2.2 with the libmysql.dll you will see the issue.

They're looking at other changes to try and solve an issue where every new thread needs to call mysql_thread_init() which isn't ideal. Until then either use the non-thread-safe version of PHP or downgrade your libmysql.dll
 [2008-06-19 11:50 UTC] Computer dot Pers at gmail dot com
So mysql dll from 5.2.1 cures the problem... 
Where i can take php 5.2.1 (or this dll)??? 
there no any live links in google...
 [2008-06-20 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, 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".
 [2008-07-14 19:39 UTC] bkeene at whisolutions dot nospamplease dot com
It looks like the system automatically closed out this ticket, but it is still an issue.

I have commented out every extension in my PHP5.2.6 installation with the exception of the php_mysql.dll OR php_mysqli.dll and still experience the problem.

Running php.exe -v on a windows 2003 box STILL takes 5 seconds.

I happened to locate a previous version of php5.1.6 (Aug 23 2006) and used that version of the libmysql.dll and the delay ceases.

At a minimum, could a valid, previous version of the libmysql.dll be bundled with the installation so that the command line versions of PHP can function correctly?

Also, I never experienced this issue with MySQL when running PHP scripts served by Apache 2.2 as a module (not CGI).
 [2008-07-20 19:58 UTC] froggywillneverdie at msn dot com
I'm using PHP 5.2.6 on Windows Vista SP1.

My scripts take around 5 seconds to exit if php_mysql.dll is enabled in php.ini.
 [2008-07-29 14:58 UTC] marcin dot slowinski at keratronik dot pl
I solved problem by copying libMySQL from my MySQL server to PHP dir.

Windows XP SP2
Apache 2.2.9 with mod_ssl
PHP 5.2.6 (crashed with oryginal libmysql.dll)
MySQL 5.0.27-community-nt

Regards
Marcin
 [2008-09-15 09:06 UTC] chris at crgs dot co dot uk
According to the MySQL bug:
http://bugs.mysql.com/bug.php?id=37226
the patch for this bug has now been created, and will be released in MySQL 5.0.70. When this happens, it would be great if the PHP people could release a new distribution with the updated libmysql.dll file inside it, so that everyone can benefit from this release without having to copy files around
 [2008-10-15 07:38 UTC] supp0rt_24x7 at yahoo dot com
Has this been fixed yet ?

http://www.eukhost.com/forums/f15/fix-error-my_thread_global_end-1-threads-didnt-exit-5612/
 [2008-11-26 21:27 UTC] cahlquist at yesco dot com
We have the same problem, 5 to 6 second delay. We have commented out every single extension except php_mysql.dll and we get the delay. Then as soon as we comment out php_mysql.dll the problem goes away.

PHP 5.2.6
Running on Microsoft Windows Server 2003 R2
IIS 6.0
CGI (NOT Fast CGI)
 [2008-11-30 11:07 UTC] paul at orac dot clara dot co dot uk
This seems fixed at long last by copying over the Libmysql.dll file supplied with MySQL 5.1.30
Hopefully that will be in the next PHP release.
 [2008-12-14 00:52 UTC] paul at orac dot clara dot co dot uk
Sadly, the clueless PHP folks have distributed the still broken 5.0.51a version of LIBMYSQL.DLL with PHP 5.2.8
LIBMYSQL.DLL 5.1.30 had been out for 3 weeks before this.

You would have thought they'd have got a grip on this by now.
How pathetic.
 [2008-12-15 22:47 UTC] chaz_meister_rock at yahoo dot com
This is still broken in 5.2.8
 [2008-12-29 18:18 UTC] chaz_meister_rock at yahoo dot com
In case anyone is wondering how to fix this, comments above give a workaround.  I'll lay out the steps for the newbies:

1) Download PHP v5.1.6 from
http://museum.php.net/php5/php-5.1.6-Win32.zip

2) Extract that zip and replace the "libmysql.dll" in your production PHP directory (probably c:\php) with the newly downloaded libmysql.dll.

This worked successfully on Windows2003 PHP v5.2.8 Threadsafe.  Also, for some reason, many other versions of libmysql.dll (either bundled with PHP or released with MySQL server) do not work correctly.

Cheers
 [2009-01-23 16:35 UTC] onehourlate at hotmail dot com
Unfortunately, libmysql.dll 5.1.30 seems crash. see #46842.

I don't know if this crash is necesserally php related, but it's still useful to investigate because trying to ship a version of libmysql.dll that finally solves this bug would be a good thing
 [2009-02-12 01:40 UTC] dbmuller at gmail dot com
I had this problem on a Windows 2003 server running PHP 5.2.5 as CGI with hsphere.  I would copy the 5.2.1 DLL in and the error would persist.  The fix was to delete the old DLL, refresh the page to produce a new error and then copy up the 5.2.1 libmysql.dll.
 [2009-02-20 03:14 UTC] kram0815 at gmx dot net
have this bug too on my system

uname -a = 2.6.26-1-amd64 Debian Lenny
php -v = PHP 5.2.6-1+lenny2
mysql -V = Ver 14.12 Distrib 5.0.51a

msg in /var/log/apache2/error.log = Error in my_thread_global_end(): 41 threads didn't exit
 [2009-03-03 00:12 UTC] chaz_meister_rock at yahoo dot com
Same error in PHP 5.2.9.
 [2009-03-10 00:14 UTC] paul at orac dot clara dot co dot uk
Libmysql.dll from Mysql 5.0.77 seems to work fine and doesn't have the problems detailed in bug #46842.
Libmysql.dll from Mysql 5.1.32 still doesn't work.

I don't know why the PHP folks have closed #46842 as Bogus when it quite clearly is not.
 [2009-03-16 16:48 UTC] chris at crgs dot co dot uk
Just to confirm that this is fixed in the updated libmysql.dll recently released as part of MySQL 5.0.77.

If you have MySQL 5.0.77 installed, just replace the copy of libmysql.dll currently provided with PHP with the version from 'C:\Program Files\MySQL\MySQL Server 5.0\bin' (or equivalent folder) and you should be good to go.

It would be great if the PHP team could update the copy of libmysql.dll supplied in the next release of PHP to 5.0.77 or above.

Thanks to all those who have worked to get this fixed.
 [2009-05-11 06:47 UTC] j_holyfield05 at hotmail dot com
This solution works perfect for me http://tinyurl.com/php-mysql-bug

PHP team should replace or update the DLL/binary in all their newer releases thankz
 [2010-10-16 00:01 UTC] felipe@php.net
-Status: No Feedback +Status: Closed
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Sat Apr 19 06:02:27 2014 UTC