From:
Operating system: xp iis
PHP version: 5.3.6
Package: *Database Functions
Bug Type: Bug
Bug description:mssql_bind not working in a loop
Description:
------------
We migrated an application from Apache/mssql to IIS/mssql. All scripts,
sprocs, etc stayed the same. Only change was to the database driver. We
have a problem in that the mssql_bind now no longer works in the foreach
loop. The exact same script does work if we explicitly bind each
variable.
//this doesn't work:
$sp_name = "proc_entity_types";
$paramArray = array();
$paramArray['mode'] = "V";
$paramArray['entity_typeId'] = "";
$paramArray['entity_type'] = "";
$paramArray['retail_type'] = "";
$paramArray['document_mapping_type'] = "";
$procRes = mssql_init($sp_name);
foreach($paramArray as $key=>$value) {
$value = trim($value);
mssql_bind($procRes,"@$key",&$value,SQLVARCHAR);
}
//this does work(!)
$procRes = mssql_init("proc_entity_types");
$mode = "V";
$entity_typeId = "";
$retail_type = "";
$document_mapping_type = "";
mssql_bind($procRes,"@mode",&$mode,SQLVARCHAR);
mssql_bind($procRes,"@entity_typeId",&$entity_typeId,SQLVARCHAR);
mssql_bind($procRes,"@entity_type",&$entity_type,SQLVARCHAR);
mssql_bind($procRes,"@retail_type",&$retail_type,SQLVARCHAR);
mssql_bind($procRes,"@document_mapping_type",&$document_mapping_type,SQLVARCHAR);
$result = mssql_execute($procRes);
//*********/
note: we've tried...
1) mssql_bind($procRes,"@$key",&$value,SQLVARCHAR);
2) mssql_bind($procRes,'@'.$key,&$value,SQLVARCHAR);
3) mssql_bind($procRes,'@'.$key,$value,SQLVARCHAR);
We've tried while loops instead of foreach...
And again, it all worked fine in apache connecting to the same db.
Test script:
---------------
//doesn't work:
$sp_name = "proc_entity_types";
$paramArray = array();
$paramArray['mode'] = "V";
$paramArray['entity_typeId'] = "";
$paramArray['entity_type'] = "";
$paramArray['retail_type'] = "";
$paramArray['document_mapping_type'] = "";
$procRes = mssql_init($sp_name);
foreach($paramArray as $key=>$value) {
$value = trim($value);
mssql_bind($procRes,"@$key",&$value,SQLVARCHAR);
}
//this does
$procRes = mssql_init("proc_entity_types");
$mode = "V";
$entity_typeId = "";
$retail_type = "";
$document_mapping_type = "";
mssql_bind($procRes,"@mode",&$mode,SQLVARCHAR);
mssql_bind($procRes,"@entity_typeId",&$entity_typeId,SQLVARCHAR);
mssql_bind($procRes,"@entity_type",&$entity_type,SQLVARCHAR);
mssql_bind($procRes,"@retail_type",&$retail_type,SQLVARCHAR);
mssql_bind($procRes,"@document_mapping_type",&$document_mapping_type,SQLVARCHAR);
$result = mssql_execute($procRes);
--
Edit bug report at http://bugs.php.net/bug.php?id=54435&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=54435&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=54435&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=54435&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=54435&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=54435&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=54435&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=54435&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=54435&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=54435&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=54435&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=54435&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=54435&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=54435&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=54435&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=54435&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=54435&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=54435&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=54435&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=54435&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=54435&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=54435&r=mysqlcfg