我目前正在尝试将我的应用程序从MySQL数据库更改为MongoDB数据库.我的项目需要比较其中的两个,我的MySQL代码正在工作,现在它给了我这个错误.
堆栈跟踪:
遇到PHP错误严重性:通知消息:未定义属性:
Users::$form_validation文件名:controllers/users.php行号:26
错误行:
$this->form_validation->set_rules('username','Username','trim|required|min_length[4]|xss_clean');
Run Code Online (Sandbox Code Playgroud)
码:
<?php
class Users extends CI_Controller{
public function register(){
$this->form_validation->set_rules('first_name','First Name','trim|required|max_length[50]|min_length[2]|xss_clean');
$this->form_validation->set_rules('last_name','Last Name','trim|required|max_length[50]|min_length[2]|xss_clean');
$this->form_validation->set_rules('email','Email','trim|required|max_length[100]|min_length[5]|xss_clean|valid_email');
$this->form_validation->set_rules('username','Username','trim|required|max_length20]|min_length[6]|xss_clean');
$this->form_validation->set_rules('password','Password','trim|required|max_length[20]|min_length[6]|xss_clean');
$this->form_validation->set_rules('password2','Confirm Password','trim|required|max_length[50]|min_length[2]|xss_clean|matches[password]');
if($this->form_validation->run() == FALSE){
$data['main_content']='users/register';
$this->load->view('layouts/main',$data);
}else{
if($this->User_model->create_member()){
$this->session->set_flashdata('registered','Registered successfully');
redirect('home/index');
}
}
}
public function login(){
//$this->load->model('user_model');
$this->form_validation->set_rules('username','Username','trim|required|min_length[4]|xss_clean');
$this->form_validation->set_rules('password','Password','trim|required|min_length[4]|max_length[50]|xss_clean');
$collection = $this->database->users;
if($this->form_validation->run() == FALSE){
$this->session->set_flashdata('login_failed', 'Sorry, this username doesn't exist.');
redirect('home/index');
} else {
$username=$_POST['login'];
$password=$_POST['password'];
$user_id = $collection->findOne(array('username' => $username, 'password' => md5($password)));
// $username = $this->input->post('username');
// $password = $this->input->post('password'); …Run Code Online (Sandbox Code Playgroud) 我目前正在研究我的JavaFX ZOO项目,我遇到了问题.我在TableView中显示所有记录,其中一列包含删除按钮.这一切都很完美,但我想点击删除按钮后出现一个警告框,只是为了安全起见.
所以我的删除按钮类看起来像这样:
private class ButtonCell extends TableCell<Record, Boolean> {
final Button cellButton = new Button("Delete");
ButtonCell(){
cellButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent t) {
Animal currentAnimal = (Animal) ButtonCell.this.getTableView().getItems().get(ButtonCell.this.getIndex());
data.remove(currentAnimal);
}
});
}
@Override
protected void updateItem(Boolean t, boolean empty) {
super.updateItem(t, empty);
if(!empty){
setGraphic(cellButton);
}
}
}
Run Code Online (Sandbox Code Playgroud)
另外,我的AlertBox类看起来像这样:
public class AlertBox {
public static void display(String title, String message){
Stage window = new Stage();
window.initModality(Modality.APPLICATION_MODAL);
window.setTitle(title);
window.setMinWidth(250);
Label label = new Label();
label.setText(message);
Button …Run Code Online (Sandbox Code Playgroud)