2016-04-29 56 views
-2

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

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') 
+0

你有一个逗号后的\“节点ID \”失踪 – markt

+0

尝试使用''',而不是'\‘',它会让你的生活更轻松 –

+1

_’这个命令时,最初跑了,因为这工作正常在mssql服务器上“_现在打印出'$ query'并将它们与你的眼睛进行比较...... –

回答

2

查询您直接MSSQL服务器上执行已逗号旁边的第二i而在PHP执行的查询不上。

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