我正在研究PHP项目,当我在localhost中尝试我的代码时,它可以正常工作。但是当我在生产服务器上尝试它时,我得到500服务器错误。我无法访问php.ini中的error_reporting。所以我找不到错误。有没有其他方法可以找到错误或错误呢?
start_shift_json.php
<?php
require_once 'include/DB_Driver_Functions.php';
$db = new DB_Driver_Functions ();
// json response array
$response = array (
"error" => FALSE
);
if (isset ( $_GET ['driver_id'] ) && isset ( $_GET ['odor_meter'] ) && isset ( $_GET['expenses'] ) && isset ( $_GET ['vehicle_registreation'] )) {
$driver_id = $_GET ['driver_id'];
$odor_meter = $_GET ['odor_meter'];
$expenses = $_GET ['expenses'];
$vehicle_registreation = $_GET ['vehicle_registreation'];
$result = $db->storeShift ( $driver_id, $odor_meter, $expenses, $vehicle_registreation );
if ($result != false) {
// use is found
$response ["error"] = FALSE;
$response ["id"] = $result ["id"];
$response ["driver_id"] = $result ["driver_id"];
$response ["start_time"] = $result ["start_time"];
$response ["odor_meter"] = $result ["odor_meter"];
$response ["expenses"] = $result ["expenses"];
$response ["vehicle_registration"] = $result ["vehicle_registration"];
echo json_encode ( $response );
} else {
// user is not found with the credentials
$response ["error"] = TRUE;
$response ["error_msg"] = "Error occured in database layer. Error:29!";
echo json_encode ( $response );
}
} else {
// required post params is missing
$response ["error"] = TRUE;
$response ["error_msg"] = "Required parameters missing!";
echo json_encode ( $response );
}
DB_Driver_Functions.php
public function storeShift($driver_id, $odor_meter, $expenses, $vehicle_registreation){
$start_time = date("Y-m-d H:i:s");
$stmt = $this->conn->prepare("INSERT INTO shifts(driver_id, start_time, odor_meter, expenses, vehicle_registration) VALUES(?, ?, ?, ?, ?)");
$stmt->bind_param("sssss", $driver_id, $start_time, $odor_meter, $expenses, $vehicle_registreation);
$storeResult = $stmt->execute();
$stmt->close();
// check for successful store
if ($storeResult) {
$stmt = $this->conn->prepare ("SELECT * FROM shifts WHERE driver_id = ?");
$stmt->bind_param ( "s", $driver_id );
$stmt->execute ();
$result = $stmt->get_result ()->fetch_assoc ();
$stmt->close ();
return $result;
} else {
return false;
}
}
这是我的桌子。
CREATE TABLE IF NOT EXISTS `shifts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`driver_id` int(11) NOT NULL,
`start_time` datetime NOT NULL,
`odor_meter` varchar(100) DEFAULT NULL,
`expenses` varchar(10) DEFAULT NULL,
`vehicle_registration` varchar(100) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `driver_id` (`driver_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
奇怪的是,当我使用参数初始化远程url时,它会插入数据,但我没有得到$ result json。相反,我得到500服务器错误。