时间:2014-02-15所属栏目: PHP/PHP框架 来源: 未知 热度:
今天在Linux上调试PHP程序,后台数据库用的是MySQL,出现如下错误:
Parse error: syntax error, unexpected $end in
检查了几次程序,都感觉没有什么错误。
最后,实在没办法了,就一行一行的逐行检查,终于发现了问题所在:
$sql = "INSERT INTO treemenu VALUES( '$i', '$ip_addr', '3', '2');
以上语句少了一个双引号,晕啊!
正确语句如下:
$sql = "INSERT INTO treemenu VALUES( '$i', '$ip_addr', '3', '2')";
故障排除。
后来在网上一查,一般缺少 标点 就出现上述情况,看来以后写程序要多留意才行啊!
NOTE:我的情况是大括号没有配对出现,少了右大括号。而且文件有342行,一直提示是343行错误!
附:原文
In PHP 5, the following error may appears as an error entry in Apache error log or simply displays on PHP web page, even if calling to php scripts with php_info() works perfectly and successfully returns information on PHP configurations:
Parse Error: syntax error, unexpected $end in ….. scripts.php on line …
The error may caused by a missing curly bracket in PHP script coding. Beside, it may also caused by error in PHP coding in class definition, as in PHP, a class definition cannot be broke up and distributed into multiple files, or into multiple PHP blocks, unless the break is within a method declaration.
But more commonly, the error is often caused by the use of Short Open tags in PHP,
To use short open tags, it must be enabled in PHP.INI. Search for short_open_tag in PHP.INI, and change the value to On. The line should look line:
short_open_tag = On