Search code examples
phpsql-serverpdounixodbc

PDO ODBC: Invalid string or buffer length


We are using a PDO to connect to a MSSQL Server using the DSN:

odbc:Driver={SQL Server Native Client 11.0};;Server=*.*.*.*;Database=whatever;

When trying to execute() an INSERT statement we are getting the following error message:

Error: SQLSTATE[HY090]: Invalid string or buffer length: 0 [Microsoft][SQL Server Native Client 11.0]Invalid string or buffer length (SQLExecute[0] at /builddir/build/BUILD/php-5.5.18/ext/pdo_odbc/odbc_stmt.c:254)

Solution

  • This error message appears to be a pretty default error message that can mean a wealth of different things.

    In our case it was simply that a parameter had been mentioned in the prepared statement but hadn't been bound. Grrrrr!