PHP mssql错误

时间:2016-04-29 23:38:02

标签: php

使用mssql模块时,我从php得到以下错误。

PHP Warning:  mssql_query(): message: Incorrect syntax near 'i'. (severity 15) in /var/www/html/inc/get_port.php on line 19
PHP Warning:  mssql_query(): General SQL Server error: Check messages from the SQL Server (severity 15) in /var/www/html/inc/get_port.php on line 19
PHP Warning:  mssql_query(): Query failed in /var/www/html/inc/get_port.php on line 19

有问题的一行是:

$query = "SELECT i.NodeID as \"NodeID\" i.InterfaceName as \"Int Name\", i.Caption, i.InterfaceAlias as InterfaceAlias, i.IfName, nd.IP_Address as \"IP Address\", nd.Caption as \"Node Name\", nd.Location, nd.machinetype From [Interfaces] as \"i\", [NodesData] as \"nd\" where i.NodeID = nd.NodeID and (nd.MachineType LIKE \"CISCO CATALYST%\" OR nd.MACHINETYPE LIKE \"PROCURVE%\") and (nd.Location LIKE \"F208%\"  and i.InterfaceAlias = \"E26\") ";

任何不喜欢我的标签的提示?最初运行时此命令,因为这在mssql服务器上运行良好

SELECT    i.NodeID as "NodeID", i.InterfaceName as "Int Name", i.Caption, i.InterfaceAlias as InterfaceAlias, i.IfName, nd.IP_Address as "IP Address", nd.Caption as "Node Name", nd.Location, nd.machinetype From [Interfaces] as i, [NodesData] as nd where i.NodeID = nd.NodeID and (nd.MachineType LIKE 'CISCO CATALYST%' OR nd.MACHINETYPE LIKE 'PROCURVE%') and (nd.Location LIKE 'F208%'  and i.InterfaceAlias = 'E26' )

1 个答案:

答案 0 :(得分:2)

直接在MSSQL服务器上执行的查询在第二个i旁边有逗号而在PHP中执行的查询没有。

$query = "SELECT i.NodeID as \"NodeID\" <- there should be a comma here