if (is_null($roomImage) || !$roomImage->save()) { $logger->LogError("Error saving room image."); foreach ($roomImage->errors as $error) { $logger->LogError($error); $errors[] = $error; } } else { $message = "Values were updated successfully!"; header("Location: room_images_list.php?room_id=" . $roomImage->roomId); } } else { if (isset($_REQUEST['room_id']) && is_numeric($_REQUEST['room_id']) && isset($_REQUEST['image_id']) && is_numeric($_REQUEST['image_id'])) { $roomId = intval($_REQUEST['room_id']); $imageId = intval($_REQUEST['image_id']); $logger->LogInfo("Page was called for image edit of room id: {$roomId} and image id: {$imageId}"); $roomImage = RoomImage::fetchFromDb($roomId, $imageId); if ($roomImage == null) { $logger->LogError("Invalid request. No gallery image with room id: {$roomId} and image id: {$imageId} exists."); $errors[] = "Invalid request. No gallery image with room id: {$roomId} and image id: {$imageId} exists."; } } else { if (isset($_REQUEST['room_id']) && is_numeric($_REQUEST['room_id'])) { $roomId = intval($_REQUEST['room_id']); $logger->LogInfo("Page was called for image add of room id: {$roomId}"); $roomImage->roomId = $roomId; } else { $logger->LogError("Invalid request. No room id was specified"); $errors[] = "Invalid request. No room id was specified"; } } }