2011-05-25 197 views
0

我有下面的代码,它运行时给我一个解析错误。我错过了明显的东西吗?

http://pastebin.com/FXxEgUB3

对不起 - 这里是完整的错误。它说,上线102,但最后标签之后是..

PHP Parse error: syntax error, unexpected $end in /var/www/cdr/outgoing_cdr.php on line 102 

我看到未闭合支架,得到了固定变量的问题,现在它变得更远,但现在我看到这些错误:

[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Notice: Array to string conversion in /var/www/cdr/outgoing_cdr.php on line 53 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Could not find stored procedure 'Array'. (severity 16) in /var/www/cdr/outgoing_cdr.php on line 53 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in /var/www/cdr/outgoing_cdr.php on line 53 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Warning: Invalid argument supplied for foreach() in /var/www/cdr/outgoing_cdr.php on line 53 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Notice: Use of undefined constant salesrep - assumed 'salesrep' in /var/www/cdr/outgoing_cdr.php on line 90 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Notice: Use of undefined constant repid - assumed 'repid' in /var/www/cdr/outgoing_cdr.php on line 91 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: message: Line 1: Incorrect syntax near ','. (severity 15) in /var/www/cdr/outgoing_cdr.php on line 97 
[Wed May 25 10:14:34 2011] [error] [client 192.168.1.10] PHP Warning: mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in /var/www/cdr/outgoing_cdr.php on line 97 

53号线有foreach语句:

foreach (mssql_query($sqla) as $sqla_res) { 
    if (!$sqla_res) 
    { 
      die('Query (1) failed.'); 
    } elseif (mssql_fetch_rows($sqla_res)==1) 
    { 
     $sqlares = $sqla_res; 
     $found = mssql_fetch_array($sqla,MSSQL_BOTH); 
     $clid = $found[clientid]; 
    } elseif (mssql_fetch_rows($sqla_res)==0) 
    { 
     break; 
    } 
} 

97号线运行此查询:

INSERT INTO $table (extension, phonenumber, calldatetime, callID, name, repID, clientID, subscribed) VALUES ($extension, $phonenumber, CURRENT_TIMESTAMP, $callID, $name, $repid, $clid, $subs) 
+1

我想你忘了else状态的右括号在线77 – 2011-05-25 14:52:27

+0

你在哪条线上得到它? – jimy 2011-05-25 14:53:07

回答

2

找到$subs = $subs_f[subscribed];并在其后添加一个}

小小提示,将您的error_reporting更改为E_ALL,查看您实际拥有多少问题!

FOREACH修正:

$resource = mssql_query($sqla); 
while($row = mssql_fetch_assoc($resource)) 
{ 
    echo $row['column']; //This is an example 
} 
+0

请参阅第2行 - error_reporting(E_ALL); :) – lorsungcu 2011-05-25 15:07:49

+0

所以你会得到错误说**常数没有定义订阅假设“订阅”** – RobertPitt 2011-05-25 15:10:29

+0

@RobertPitt - 不,请参阅上面的新错误 – lorsungcu 2011-05-25 15:25:49

0
} else { 
     $sql_subs = "SELECT subscribed FROM $tbl_mkt WHERE clientid = $clid"; 
     $subs_res = mssql_query($sql_subs); 
     if (!$subs_res) { 
      die('Query (2) failed.'); 
     } else { 
       $subs_f = mssql_fetch_array($sqla,MSSQL_BOTH); 
       $subs = $subs_f[subscribed]; 
} 

第二别的块没有右大括号。

+0

关闭这个,现在看到新的,无关的错误。有任何想法吗? – lorsungcu 2011-05-25 15:27:37

0

关闭打开的braсket线后79

0

两个问题,我注意到:

  • else起始线#77有没有大括号}(原因你的错误)
  • 线# 99而不是if (!$sql)你可能本意是有if (!$result)
+0

谢谢,得到了这两个。还错误地称为$ cidnumber;应该是$ phonenumber。 – lorsungcu 2011-05-25 15:26:38

+0

不客气。 – anubhava 2011-05-25 15:30:01