2016-04-29 70 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