Php is poorly formed?
when my site loads it stops halfway due to specific PHP code. When I try to comment out the PHP code, the whole page loads correctly (input fields, buttons, etc.)
This is the code causing the problem
<?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();
?>
+2
a source to share
3 answers
I doubt it has corrupted the code (parser error). I would recommend turning on error reporting so you can see the error on screen or check your apache error logs. This will probably lead to some kind of runtime error. Without error or function code deleteItem
, saveInstance
, listItems
it is impossible to say.
+2
a source to share