A query I wrote in PHP for a SQL Server database is having an issue where a word is not being recognized as the table name. I’m using SQL Server for PHP 2.0 (VC6). The following query works and returns all orders from the table Order when executed in SQL Server Management Studio.
SELECT * FROM "db_name"."dbo"."Order" (also tried using brakets [] around table name)
In PHP, I get the following error:
[0] => Array
(
[0] => IMSSP
[SQLSTATE] => IMSSP
[1] => -35
[code] => -35
[2] => Invalid type
[message] => Invalid type
)
This query works within the PHP code for all other tables in the database, db_name.. it just won’t work for table Order, and that is the correct table name. I tried double quote, rectangular brackets, no quote/bracket, etc. to to no avail. Does anyone have an idea how to fix this?
** UPDATE:
I found a solution to this. Please take a look at one of the answers for the fix or work-around.
Something must be going on in PHP or your driver. You should be able to use the SQL Server Profiler to see the actual query being submitted.
In any case, if you can’t find out what it’s doing. You could consider this as a workaround:
And move on – life’s too short.