Error: A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Skill::delskill()
Filename: controllers/Skill.php
Line Number: 75
Backtrace:
File: /var/www/html/tatui/application/controllers/Skill.php
Line: 75
Function: _error_handler
File: /var/www/html/tatui/index.php
Line: 292
Function: require_once
//下面是代码,剩下的代码运行良好
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Skill extends CI_Controller
{
function __construct()
{
parent::__construct();
//$this->load->library('session');
$this->load->helper(array('form', 'url', 'html'));
$this->load->library('form_validation');
}
public function construct_pages($page, $data) {
$this->load->view('templates/header', $data);
$this->load->view('pages/'.$page);
$this->load->view('templates/footer');
}
// checks login using in built validation
public function index()
{
$this->load->helper('form');
$this->load->view('pages/AddSkill');
}
public function skill_validate(){
$this`enter code here`->load->library('form_validation');
$this->form_validation->set_rules('skillid', 'skillid', 'required|max_length[15]');
$this->form_validation->set_rules('skillname', 'SkillName', 'required|max_length[25]');
$this->form_validation->set_rules('skilldescription', 'skilldescription', 'required|max_length[70]');
$this->form_validation->set_rules('skillgroup', 'skillgroup', 'required');
if($this->form_validation->run()){
$this->load->model('Getskills', '', TRUE);
$skill = $this->input->post('skillid');
$skillExisted = $this->Getskills->getskill($skill);
if($skillExisted){
echo "Skill Already Existed";
$this->load->helper('form');
$this->load->view('pages/AddSkill');
}
else{
$data = array(
'SkillId' => $this->input->post('skillid'),
'SkillDescription' => $this->input->post('skilldescription'),
'SkillGroup' => $this->input->post('skillgroup'),
'SkillName' => $this->input->post('skillname')
);
$inserted = $this->Getskills->insert_skill($data);
if($inserted){
echo "Inserted Successfully";
$this->load->view('pages/AddSkill');
}
else{
echo "Please contact Support Team";
}
}
}
else{
echo "Please contact Support Team";
}
}此部分是否工作不正常?
public function delskill($data) {
$this->db->where(array('Skillid' , 'Skillname' , 'Skillgroup' , 'Skilldescription'));
$this->db->delete('Skills');
}
}有没有人知道它不工作的真正原因?
发布于 2016-10-22 21:38:10
根据你的问题,它显示了像Skill:: delskill ()缺少参数1这样的错误,这意味着你在调用delskill函数的任何地方都没有传递任何参数,但是你已经用一个参数创建了这个函数,作为公共函数delskill($data){...},所以,你需要将一个参数传递给delskill函数。但是我看了你的delskill函数,它没有用,因为你没有使用传递给那个函数的参数,这个函数的条件是错误的。
发布于 2016-10-23 02:38:28
如果您不确定总是发送默认参数,则需要向方法或函数发送默认参数。
public function delskill($data = '') {
if (isset($data) && is_array($data)) {
$this->db->where(array('Skillid' , 'Skillname' , 'Skillgroup' , 'Skilldescription'), $data);
$this->db->delete('Skills');
}
}注意:根据您的代码,您将从多个列中删除。如果您以args格式发送空白数据,并且它执行查询,那么您将面临数据丢失问题。确保你总是发送有效的删除请求,有一个安全的SQL。
https://stackoverflow.com/questions/40192510
复制相似问题