Q:

INSERT INTO sqlsrv_query statement not working

When working with the sqlsrv_query command I can request data from the MSSQL server.
This works
But!
When I want to add data it returns the error [error:array].
The code I use for this is:
$tsql= "INSERT INTO dbo.VERLOF_events (id,
                username,
                soort,
                afdeling,
                description,
                evdate,
                trdate) 
                VALUES
                (?, ?, ?, ?, ?, ?, ?)";
                $var = array('', $username, $soort, $afdeling,     $description, $evdate, $trdate);
                if (!sqlsrv_query($conn, $tsql, $var))
                     {
                die('Error: ' . sqlsrv_errors());
                     }
                echo "1 record added"; 

The array values are set in the POST statement.
$afdeling = $row['Afdeling'];
$submit = @$_POST['submit'];
$description = @$_POST["description"];
$evdate = @$_POST["evdate"];
$trdate = @$_POST["trdate"];
$username = @$_SESSION['username'];
$soort = @$_POST['Dagen'];

Why does it return the array error?
I looked it up but could not find the problem returning the error.
Any help is appreciated!

A:

The problem is probably you're trying to add an empty value in the id field. If you set identity on it with auto-numbering, you don't need to include it in your query :
$tsql= "INSERT INTO dbo.VERLOF_events (
            username,
            soort,
            afdeling,
            description,
            evdate,
            trdate) 
            VALUES
            (?, ?, ?, ?, ?, ?)";
            $var = array($username, $soort, $afdeling,     $description, $evdate, $trdate);
            if (!sqlsrv_query($conn, $tsql, $var))
                 {
            die('Error: ' . sqlsrv_errors());
                 }
            echo "1 record added"; 

