【发布时间】:2010-05-18 02:13:48
【问题描述】:
当我的网站加载时,由于特定的 php 代码,它会在中途停止。当我尝试注释掉 php 代码时,整个页面正确加载(输入框、按钮等)
这是导致问题的代码
<?php
//if the add location button is clicked, the add location, the whole form will not be submitted
if($_REQUEST['command'] == 'Add'){
if($_POST['companyLocation'] == ""){
$errmsg="Please enter a location1";
}
elseif($_POST['companySize'] == ""){
$errmsg="Please enter a size for the location";
}
else{
$location = Location::instance();
$testing = $location->doesExist($_POST['companyLocation']);
if ($testing == true){
$errmsg="Location already exists";
}
else{
$objLocation = new Obj_Location();
$objLocation->set_Name($_POST['companyLocation']);
$objLocation->set_Size($_POST['companySize']);
$location->addLocation($objLocation);
$location->saveInstance();
}
}
}
//this is the part that breaks! when I comment it out, the page loads properly.
$location = Location::instance();
$location->deleteItem($_GET["item"]);
$location->saveInstance();
$location->listItems();
?>
【问题讨论】:
-
你得到什么错误?
-
其实PHP语法没问题。也许你应该看一下日志,这样你就知道出了什么问题。
-
愚蠢的问题,但是如何在ubuntu中读取apache的错误日志?而且我只能ssh,所以我只使用命令行。
-
除非 Apache 被修改为将日志发送到别处,它应该在 /var/log/httpd/error.log
-
有谁知道我的编码方法是否是 php 5.2.10 的“新”方法?阻塞代码的服务器是 php5.2.4。只是我注意到的一个差异......