From: maxcamo at gmail dot com
Operating system: Win2003
PHP version: 5.2CVS-2009-03-05 (snap)
PHP Bug Type: MSSQL related
Bug description: MSSQL: "Changed database context to" when connecting
Description:
------------
Hi,
with MSSQL 2005,Apache 2.2.11 and PHP 5.2.6 i get this error when i
try to connect to the db
Changed database context to
The error raise up when I try to connect to the DB.
connections timeout are high
mssql.connect_timeout = 300
mssql.timeout = 300
It happen randomly, but more frequently when the site traffic si very
high
Reproduce code:
---------------
$Maxtries=60;
$delayMin=50000;
$delayMax=100000;
$delay=rand($delayMin,$delayMax);
$log_filename="conn_failed.log";
$tries=1;
$connDb = @mssql_connect($host, $user, $pwd));
if ($connDb)
mssql_select_db($db, $connDb);
while(!$connDb){
if ($tries>=$Maxtries){
//echo "Database failed to respond.";
$fp = fopen($log_filename,"a+");
fputs($fp, gmdate("M d Y H:i:s") . ": Errore Connessione \r\n");
fclose($fp);
exit;
}
usleep($delay*$tries);
$connDb = @mssql_connect($host, $user, $pwd));
if ($connDb)
mssql_select_db($db, $connDb);
$tries++;
}
if ($tries>1){
$fp = fopen($log_filename,"a+");
fputs($fp, gmdate("M d Y H:i:s") . ":: Try:$tries ::
".$ServerName."::
".mssql_get_last_message()." :: ". $pageName . "\r\n");
fclose($fp);
}
Expected result:
----------------
Db Connection
Actual result:
--------------
Mar 05 2009 21:08:19:: Try:2 :: B-C2N1:: Il contesto di database è
stato sostituito con 'dbName'. :: /index.html
Mar 05 2009 21:08:20:: Try:8 :: B-C2N1:: Il contesto di database è
stato sostituito con 'dbName'. :: /page2.html
Mar 05 2009 21:09:26:: Try:6 :: B-C2N1:: Il contesto di database è
stato sostituito con 'dbName'. :: /page3.html
--
Edit bug report at http://bugs.php.net/?id=47580&edit=1
--
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47580&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47580&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47580&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47580&r=fixedcvs
Fixed in CVS and need be documented:
http://bugs.php.net/fix.php?id=47580&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47580&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=47580&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=47580&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=47580&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=47580&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=47580&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=47580&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=47580&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47580&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=47580&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=47580&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=47580&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=47580&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=47580&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=47580&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=47580&r=mysqlcfg