将多个参数传递给SQL存储过程PHP

时间:2015-08-10 21:42:35

标签: php sql sql-server

我正在尝试通过PHP在我的SQL DB上执行存储过程。我看到了一个如何只将一个参数传递给存储过程的示例。 我该如何发送这两个参数?用户和psw?

 $conn = sqlsrv_connect($server, array("UID"=>$user, "PWD"=>$pwd_db, "Database"=>$db));

 if($conn == false)
 {
     die(print_r(sqlsrv_errors()));
 }
 //prepare the storedprocedure
 $outputStoredProcedure = 1;
 $storedProcedureCall = "{call Login_Software( ?, ?)}";

 $arrPar = array();
 $arrPar = array($email,$password);

 $params = array(
     array($arrPar,SQLSRV_PARAM_IN),
     array($outputStoredProcedure, SQLSRV_PARAM_INOUT)
 );


 $stmt = sqlsrv_query($conn,$storedProcedureCall,$params);
 if($stmt === false)
 {
     echo "Falhou ao executar a storedprocedure\n";
     die(print_r( sqlsrv_errors(), true));
 }

 sqlsrv_close($conn);

在代码末尾,$stmt为false,错误打印打印:

Array
(
    [0] => Array
        (
            [0] => IMSSP
            [SQLSTATE] => IMSSP
            [1] => -16
            [code] => -16
            [2] => An invalid PHP type for parameter 0 was specified.
            [message] => An invalid PHP type for parameter 0 was specified.
        )

)

0 个答案:

没有答案