I am executing a MSSQL stored procedure that is supposed to return an output parameter (ErrCode), as well as a resultset.
I am calling the procedure from PHP using the following code, but so far have been unable to retrieve the output parameter:
$stmt = mssql_init("addFaculty", $this->db);
mssql_bind($stmt, "@FacultyID", $FacultyID, SQLCHAR);
...imagine other parameters here...
mssql_bind($stmt, "@ErrCode", &$ErrCode, SQLINT1, TRUE, FALSE, 1);
$result = mssql_execute($stmt);
echo $ErrCode
$ErrCode is always echoed as 0, even when it should return a '1' or '2'. When I execute the procedure within SQL Server Studio, however, the 'Messages' tab will correctly display a '1' or a '2'.
In doing research, I found one suggestion that stated you must use mssql_next_result() first to be able to access the output parameters. I tried this, but it simply returned a PHP "Warning: mssql_next_result(): supplied argument is not a valid MS SQL_result resource"
I also found a reference to a similar issue in this thread but did not see a real resolution.
Like the person in that thread, I am using Linux (CentOS) with PHP5 and MS SQL Server 2005.
Does anyone have any suggestions on this? I had an issue like this in a previous project as well, and in the end, simply gave up on using output parameters (and did all my error_checking in the PHP instead) because I couldn't figure it out. It would be nice to find an answer :(