开发者

PHP Parse error - unexpected $end [closed]

开发者 https://www.devze.com 2023-03-08 03:20 出处:网络
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time,or an extraordinarily narrow situation that is not generally applic
This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 10 years ago.

I have the following code, and it's giving me a parse error when run. Am I missing something obvious?

http://pastebin.com/FXxEgUB3

Sorry - here's the full error. It says on line 102, but that's after the last tag..

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

I see the unclosed bracket, got that, fixed the variable issues, now it's getting much further, but am seeing these errors now:

[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

Line 53 has the foreach statement:

foreach (mssql_query($sqla) as $sqla_开发者_如何学Gores) {
    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;
    }
}

Line 97 is running this query:

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


Find $subs = $subs_f[subscribed]; and add a } just after.

A little tip, change your error_reporting to E_ALL, see how many issues you actually have!

Foreach Fix:

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


} 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];
}

The second else block has no closing curly brace.


Close the opened braсket after line 79.


Two problems I notice:

  • else starting at line # 77 has no closing brace } (reason of your error)
  • On line # 99 instead of if (!$sql) you probably meant to have if (!$result)
0

精彩评论

暂无评论...
验证码 换一张
取 消