ID: 33963 User updated by: paul dot robinson at groupbc dot com Reported By: paul dot robinson at groupbc dot com -Status: Feedback +Status: Open Bug Type: MSSQL related Operating System: Linux (RHEL 4) PHP Version: 5.0.4 New Comment:
Patches suggested are against Snapshot: php5-STABLE-200508021038.tar.gz Although I haven't actually built an example using that snapshot today I have looked at the code which since it is unchanged would seem to exhibit the same problem. Previous Comments: ------------------------------------------------------------------------ [2005-08-02 18:34:32] [EMAIL PROTECTED] Please try using this CVS snapshot: http://snaps.php.net/php5-latest.tar.gz For Windows: http://snaps.php.net/win32/php5-win32-latest.zip ------------------------------------------------------------------------ [2005-08-02 13:39:23] paul dot robinson at groupbc dot com Description: ------------ Using FreeTDS 0.63 (latest stable release), calling mssql_bind can fail due to the restrictions placed on parameters by the dbrpcparam function from FreeTDS. One specific example is an input parameter must have maxlen==-1. With the code as is in PHP 5.0.4 a NULL valued variable length type input parameter will always have maxlen==0 thereby always failing. Diff below shows changes to ext/mssql/php_mssql.c that address this parameter mismatch. 2025,2026c2025,2029 < maxlen=0; < datalen=0; --- > datalen = 0; > if (is_output) > maxlen = -1; > else > maxlen = -1; 2030d2032 < datalen=Z_STRLEN_PP(var); 2031a2034,2046 > > if (is_output) { > if ((maxlen > 0 ) && (maxlen < 256)) > datalen = maxlen; > else { > maxlen = 255; > datalen = 255; > } > } > else { > maxlen = -1; > datalen=Z_STRLEN_PP(var); > } Reproduce code: --------------- mssql_bind($query, "@varchar1", $varchar1, SQLVARCHAR); or mssql_bind($query, "@varchar1", $varchar1, SQLVARCHAR, false, true, 57); Expected result: ---------------- Sucessfully bind input variable. Actual result: -------------- "Unable to set parameter" i.e. FAIL is returned by the call to dbrpcparam in PHP_FUNCTION(mssql_bind). ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=33963&edit=1