I'm using PHP PDO with MS SQL server using sqlsrv
driver. I'm running a procedure that has to insert some data and I see that the insert is done as it's entered to the database. But I still get an error in return, the error says
Array ( [0] => 42000 [1] => 8114 [2] => [Microsoft][SQL Server Native Client 11.0][SQL Server]Error converting data type nvarchar to int. )
This is part of the stored procedure
and here is the relevant piece of code
$stmt = $dbh->prepare("UsersManagement.spUsersInsert :InsertUser, :UserName, :FirstName");
$stmt->bindParam('InsertUser', $_SESSION['user_id'], PDO::PARAM_INT);
$stmt->bindParam('UserName', $_POST['username']);
$stmt->bindParam('FirstName', $_POST['first_name']);
if ($stmt->execute()) {
echo 'OK';
} else {
print_r($stmt->errorInfo());
}
You can see that I've explicitly said PDO::PARAM_INT
where it requires an integer, so what could the error be?