php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35920 mssql_bind(): Unable to set parameter
Submitted: 2006-01-06 16:19 UTC Modified: 2006-01-14 17:54 UTC
From: eaboyle at gemstonewd dot com Assigned: fmk (profile)
Status: Not a bug Package: MSSQL related
PHP Version: 5CVS, 4CVS (2006-01-07) (snap) OS: window XP pro
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: eaboyle at gemstonewd dot com
New email:
PHP Version: OS:

 

 [2006-01-06 16:19 UTC] eaboyle at gemstonewd dot com
Description:
------------
I'm trying to get output from an mssql stored procedure.

I get "mssql_bind(): Unable to set parameter warning on line  6. 

I have "allow_call_time_pass_reference = On" in my php.ini.



Reproduce code:
---------------
1 $db = new clsDBsqlRags();
2 $db->connect();
3 $stmt=mssql_init("sp_NEXT_ACT_NUM ",$db->Link_ID); 
4 $act_base = 1;
5 mssql_bind($stmt,"@ACT_BASE", $act_base, SQLINT4);
6 mssql_bind($stmt, "RTNVAL", &$act_num, SQLINT4);
7
8 $result=mssql_execute($stmt, FALSE);

Stored procedure:



CREATE PROCEDURE sp_NEXT_ACT_NUM     
  @ACT_BASE int
AS

  DECLARE 
    @Act int                 --FETCHED CLIENT.ACCOUNT VALUE

  --GET SET OF ACCOUTS FROM CLIENT TABLE
  DECLARE Crsr_Act CURSOR
  FOR 
    SELECT C.ACCOUNT
    FROM CLIENT C
    WHERE C.ACCOUNT >= @ACT_BASE
    ORDER BY ACCOUNT

  OPEN Crsr_Act

  FETCH Crsr_Act INTO @Act

  --TRAVERSE Crsr_Act
  WHILE (@@FETCH_STATUS = 0)
  BEGIN

    IF @ACT_BASE < @Act 
      BREAK
    ELSE IF @ACT_BASE = @Act
      SELECT @ACT_BASE = @ACT_BASE + 1

    FETCH Crsr_Act INTO @Act

  END

  CLOSE Crsr_Act
  DEALLOCATE Crsr_Act

  RETURN @ACT_BASE


GO


Expected result:
----------------
expect $act_num to be set to the return value of the mssql stored procedure.

Actual result:
--------------
mssql_bind(): Unable to set parameter warning on line  6. 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-01-06 16:48 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.1-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.1-win32-latest.zip


 [2006-01-06 23:58 UTC] eaboyle at gemstonewd dot com
I upgraded to 5.1.latest and still get the same result.
 [2006-01-07 00:22 UTC] sniper@php.net
Assigned to the maintainer.
 [2006-01-14 15:45 UTC] none at none dot com
won't $result ccontain the response object from the stored proc ? 

i.e. your passing in two params, where your procedure expects one, hence your unable to set the invalid parameter.

for example, do you just need to use mssql_next_result / mssql_fetch_row on $result to get the output?

Paul
 [2006-01-14 17:54 UTC] fmk@php.net
The name of the returnvalue is RETVAL and not RTNVAL.

mssql_bind will fail if it can't find the parameter or return value.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 17:01:58 2024 UTC