|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24595 Cannot bind output variables.
Submitted: 2003-07-10 12:35 UTC Modified: 2003-08-06 11:14 UTC
Avg. Score:2.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: hans at velum dot net Assigned:
Status: Not a bug Package: MSSQL related
PHP Version: 5.0.0b1 (beta1) OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: hans at velum dot net
New email:
PHP Version: OS:


 [2003-07-10 12:35 UTC] hans at velum dot net
When using mssql_bind() to bind an output variable, the variable is passed into the stored procedure but the modified value is not returned.  (The variable is being passed by reference to mssql_bind()).

Reproduce code:
I used the following user-contributed example from mssql_execute manual page.

if we have this procedure: 

  @sval varchar(50) OUTPUT, 
  @intval int OUTPUT, 
  @floatval decimal(6,4) OUTPUT 
) AS 

if @intval is null 
select '@intval is null' as answer 
select '@intval is NOT null' as answer 

set @sval='Hello ' + @sval 
set @intval=@intval+1 
set @floatval=@floatval+1 

return 10 

We can use this PHP code: 



if ($conn) { 





print ("Answer: " . $arr[0] . "
" ); 
print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string = $sval"); 

else print("ooops!"); 

Expected result:
Answer: @intval is NOT nullRETVAL = 10 ; intval = 12 ; floatval = 3.1416 ; string = Hello Frank

Actual result:
Answer: @intval is NOT nullRETVAL = 0 ; intval = 11 ; floatval = 2.1416 ; string = Frank


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-10 12:52 UTC]
Does this happen with PHP 4.3.2 ?

 [2003-07-10 14:38 UTC] hans at velum dot net
Yes, I verified that this is also happening with 4.3.2.  I thought, based on a comment in the manual, that this was not an issue in the 4.3.2 release.

I also verified that the bound values are making it *into* the stored procedure w/o incident.  (E.g. I can add them to the returned result row to see that the stored procedure is aware of the values.)
 [2003-08-05 12:20 UTC] brian_caughlin at hotmail dot com
I ran into this issue myself in 4.3.2, and found that the workaround is to use the mssql_next_result() function before attempting to access the retval and any output parameters.  I also found that I don't need to pass the variables by reference.

Here is the code that works for me in 4.3.2:



if ($conn) { 





print ("Answer: " . $arr[0] . "
" ); 
print ("RETVAL = $val ; intval = $ival ; floatval = $fval ; string =

else print("ooops!"); 

I hope this helps!
 [2003-08-05 13:31 UTC] brian_caughlin at hotmail dot com
By the way, it looks like this bug may be a duplicate of Bug #21089.  Perhaps this is simply an undocumented change.
 [2003-08-05 18:32 UTC]
Please try using this CVS snapshot:
For Windows:

and also read the comments in bug #21089

 [2003-08-06 10:38 UTC] brian_caughlin at hotmail dot com
This is to confirm that the same behaviour manifests itself in the latest CVS snapshot, and also that the methods described in the comments for Bug #21089 apply here.  This appears to be a change that took place in 4.3 which continues to apply to 5.0.  The documentation should be updated to reflect this change.
 [2003-08-06 11:14 UTC]
Same as bug #21089

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Dec 07 18:01:29 2023 UTC