views:

21

answers:

0
+1  Q: 

PDO FreeTDS error

I have just upgraded my server from php 5.2 to 5.3.3 and I am having a weird error in PDO (with DBLIB).

I am connecting to an SQL Server 2005. I am having The error appears in any statement that prefixes a parameter with the "N" letter (to tell SQL Server that it's a unicode string).

The query looks like this:

INSERT INTO IPs (IP, PosterId, Note, DateAdded, Status, IsClass)
VALUES (:ip, :posterid, N:note, GETUTCDATE(), :status, :isclass)

Used to work properly on the old setup, the new one throws an exception:
SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Seems to work properly if I remove the N character in front of the parameter. However, I have thousands of statements like that and it would be a pain o remove. I would rather find out why this happens and fix it.

Any idea how to make this work?

Thanks

Later edit: Thanks to stillstanding below, I found that using non named parameters (question mark) works. But it still leaves me with changing lots of statements.

So this works:

INSERT INTO IPs (IP, PosterId, Note, DateAdded, Status, IsClass)
VALUES (?, ?, N?, GETUTCDATE(), ?, ?)