|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-02-07 22:48 UTC] tony2001@php.net
[2007-02-07 23:19 UTC] rnerovich at gmail dot com
[2007-02-07 23:27 UTC] tony2001@php.net
[2007-06-21 10:12 UTC] smargroth at hotmail dot com
[2008-03-04 16:22 UTC] alexr at oplot dot com
[2014-12-29 01:05 UTC] kalle@php.net
-Status: Assigned
+Status: Open
-Assigned To: fmk
+Assigned To:
[2016-10-15 23:10 UTC] kalle@php.net
-Status: Open
+Status: Wont fix
[2016-10-15 23:10 UTC] kalle@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 19:00:02 2025 UTC |
Description: ------------ When using mssql_bind() to pass an empty string to a stored procedure, the empty string is converted to NULL. This problem has been reported by others, but either closed or marked as BOGUS, which is not the case, as I've reproduced this on both development and deployed systems. Reproduce code: --------------- CREATE PROCEDURE REC_PROC_INSERT_MS_INTF @UCODE UNIQUEIDENTIFIER, @PHONE VARCHAR(10), @ACCOUNT VARCHAR(25), @EALOC VARCHAR(38), @TIME DATETIME, @RECID UNIQUEIDENTIFIER, @PRBSTR VARCHAR(30) AS SELECT @UCODE as ucode, @PHONE as phone, @ACCOUNT as account, @EALOC as ealoc, @TIME as time, @RECID as recid, @PRBSTR as prbstr RETURN 1 GO $sp = mssql_init('REC_PROC_INSERT_MS_INTF',$dblink->dbresource); mssql_bind($sp,"RETVAL",&$rc,SQLINT4,TRUE,TRUE,4); mssql_bind($sp,"@UCODE",$ucode,SQLVARCHAR,FALSE,FALSE,strlen($ucode)); mssql_bind($sp,"@PHONE",$phone,SQLVARCHAR,FALSE,FALSE,10); mssql_bind($sp,"@ACCOUNT",$account,SQLVARCHAR,FALSE,FALSE,25); mssql_bind($sp,"@EALOC",$ealoc,SQLVARCHAR,FALSE,FALSE,38); mssql_bind($sp,"@TIME",$currtime,SQLVARCHAR,FALSE,FALSE,strlen($currtime)); mssql_bind($sp,"@RECID",$recId,SQLVARCHAR,FALSE,FALSE,strlen($recId)); mssql_bind($sp,"@PRBSTR",$problem,SQLVARCHAR,FALSE,FALSE,30); $result = mssql_execute($sp); if($result){ $row = mssql_fetch_array($result); global $log; $log->Writelog(var_export($row,true)); } Expected result: ---------------- I would expect the empty strings to stay empty. This causes major problems with NON-NULLABLE SQL fields!!! array ( 0 => '?k?#???M?T??S???', 'ucode' => '?k?#???M?T??S???', 1 => '', 'phone' => '', 2 => '', 'account' => '', 3 => '423998059-130628001', 'ealoc' => '423998059-130628001', 4 => '2007-02-07 16:20:54', 'time' => '2007-02-07 16:20:54', 5 => 'g?r}Q\'N??@I?*?', 'recid' => 'g?r}Q\'N??@I?*?', 6 => '', 'prbstr' => '', ) Actual result: -------------- when any of the strings (not uniqueidentifiers) are set to an empty string ($phone = '') the following is received from the var_export() array ( 0 => '?k?#???M?T??S???', 'ucode' => '?k?#???M?T??S???', 1 => NULL, 'phone' => NULL, 2 => NULL, 'account' => NULL, 3 => '423998059-130628001', 'ealoc' => '423998059-130628001', 4 => '2007-02-07 16:20:04', 'time' => '2007-02-07 16:20:04', 5 => 'g?r}Q\'N??@I?*?', 'recid' => 'g?r}Q\'N??@I?*?', 6 => NULL, 'prbstr' => NULL, ) the GUIDS look like garbage, but are correct. The strings however are all NULL if they were sent in as '' This is what var_export() reports if all strings are set to ' ' (one space) array ( 0 => '?k?#???M?T??S???', 'ucode' => '?k?#???M?T??S???', 1 => ' ', 'phone' => ' ', 2 => ' ', 'account' => ' ', 3 => '423998059-130628001', 'ealoc' => '423998059-130628001', 4 => '2007-02-07 16:20:54', 'time' => '2007-02-07 16:20:54', 5 => 'g?r}Q\'N??@I?*?', 'recid' => 'g?r}Q\'N??@I?*?', 6 => ' ', 'prbstr' => ' ', )