mssql_bind binds by reference, not by value, even on input parameters. Improper binding can cause strange errors; in my case "Error converting data type varchar to int"
--SAMPLE STORED PROCEDURE
CREATE Procedure [dbo].[myproc]
(
@one VARCHAR(10) = 'n1',
@two VARCHAR(10) = 'n2',
@three VARCHAR(10) = 'n3',
@four VARCHAR(10) = 'n4',
@five VARCHAR(10) = 'n5'
)
AS
BEGIN
SET NOCOUNT ON;
SELECT
@one AS 'one',
@two AS 'two',
@three AS 'three',
@four AS 'four',
@five AS 'five'
END
//SAMPLE PHP CALL
$sp_name = 'mydb.dbo.myproc';
$proc = mssql_init($sp_name);
$sp_parms->one = 'one';
$sp_parms->two = 'two';
$sp_parms->three = 'three';
foreach ($sp_parms as $key=>$parm) {
#THIS FAILS, because it's binding values!
#mssql_bind($proc, '@'.$key, $parm, SQLVARCHAR)
# or die("Unable to bind $sp_name:$key<br>".mssql_get_last_message());
#THIS SUCCEEDS, USES A REFERENCE
mssql_bind($proc, '@'.$key, $sp_parms->$key, SQLVARCHAR)
or die("Unable to bind $sp_name:$key<br>".mssql_get_last_message());
}