이 프로젝트를 잠시 떠난 후 다시 작업을 시작합니다. 나는 그것을 떠났을 때 작동했다고 맹세하지만 데이터베이스에 항목을 추가하고 삭제 및 편집하는 동안 오류가 발생하는 것 같습니다. 내 "생성"기능으로 범위를 좁혔다 고 생각합니다.
public function create() {
if (!filter_has_var(INPUT_POST, 'name') ||
!filter_has_var(INPUT_POST, 'type') ||
!filter_has_var(INPUT_POST, 'rent_cost') ||
!filter_has_var(INPUT_POST, 'rental_duration') ||
!filter_has_var(INPUT_POST, 'level') ||
!filter_has_var(INPUT_POST, 'image') ||
!filter_has_var(INPUT_POST, 'description')) {
return false;
}
$name = filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
$type = filter_input(INPUT_POST, "type", FILTER_SANITIZE_STRING);
$rent_cost = filter_input(INPUT_POST, "rent_cost", FILTER_SANITIZE_STRING);
$rental_duration = filter_input(INPUT_POST, "rental_duration", FILTER_SANITIZE_STRING);
$level = filter_input(INPUT_POST, "level", FILTER_SANITIZE_STRING);
$image = filter_input(INPUT_POST, "image", FILTER_SANITIZE_STRING);
$description = filter_input(INPUT_POST, "description", FILTER_SANITIZE_STRING);
try {
if (!is_numeric($rent_cost OR $rental_duration OR $level)) {
throw new DataTypeException(gettype($rent_cost OR $rental_duration OR $level), "number");
}
if ($name OR $type OR $rent_cost OR $rental_duration OR $level OR $image OR $description == "") {
throw new RequiredValueException("Fatal Error: <br> Please complete all fields");
}
$new_rentalpokemon = new Rentalpokemon($name, $type, $rent_cost, $rental_duration, $level, $image, $description);
$this->rentalpokemon_model->add_rentalpokemon($new_rentalpokemon);
$view = new RentalpokemonDetail();
$view->display($new_rentalpokemon);
} catch (RequiredValueException $ex) {
echo $message = $ex->getMessage();
} catch (DataTypeException $ex) {
echo $message = $ex->getMessage();
} catch (Exception $ex) {
echo $message = $ex->getMessage();
}
try 루프는 무슨 일이 있어도 오류가 발생하는 것처럼 보이며 정보를 올바르게 읽지 않았기 때문이라고 생각합니까?
try 루프에서 if 문 중 하나를 주석 처리하면 다른 하나가 추가하려고 할 때 오류가 발생합니다. 따라서 정보를 입력 한 경우에도 try 루프에 나와있는 것처럼 모든 필드를 완료해야한다는 메시지가 표시됩니다. 왜 막힐 수 있는지 아십니까? 나는 그것을 알아낼 수없는 것 같다. 더 많은 정보가 필요하면 알려 주시고 도움이 필요하시면 미리 감사드립니다.
if 문의 구문은 약간 벗어 났으며 다음 줄을 따라 시도해보십시오.
if(!is_numeric($rent_cost) || !is_numeric($rental_duration))
과
if($name == "" || $cost == "")
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다