我有以下代码,它在运行时给我一个解析错误。我错过了一些明显的东西吗?
抱歉 - 这是完整的错误。它在第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)
答案 0 :(得分:2)
查看$subs = $subs_f[subscribed];
并在之后添加}
。
小提示,将您的error_report更改为E_ALL
,看看您实际拥有多少问题!
Foreach Fix:
$resource = mssql_query($sqla);
while($row = mssql_fetch_assoc($resource))
{
echo $row['column']; //This is an example
}
答案 1 :(得分: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];
}
第二个其他区块没有结束大括号。
答案 2 :(得分:0)
在第79行后关闭打开的braсket。
答案 3 :(得分:0)
我注意到两个问题:
else
没有右括号}
(出错的原因)if (!$sql)
,你可能想要if (!$result)