php - ArgumentCountError 函数 1 的参数太少,正好传入 9 个
问题描述
我在 codeigniter 上有以下错误
消息:函数 ManageSupplierfull::updatesupplier() 的参数太少,在第 532 行的 C:\Program Files (x86)\Ampps\www\codetest\system\core\CodeIgniter.php 中传递了 1 个,预期正好 9 个
我的控制器ManageSupplierfull.php
public function updatesupplier($name,$email,$phone,$company,$address,$city,$region,$country,$postbox) {
$result['data']=$this->NewSuppliermodel->updaterecords($get['sid']);
if($this->input->post('update'))
{
$name=$this->input->post('name');
$email=$this->input->post('email');
$phone=$this->input->post('phone');
$company=$this->input->post('company');
$address=$this->input->post('address');
$city=$this->input->post('city');
$region=$this->input->post('region');
$country=$this->input->post('country');
$postbox=$this->input->post('postbox');
$result['data']=$this->NewSuppliermodel->updaterecords($name,$email,$phone,$company,$address,$city,$region,$country,$postbox);
$this->session->set_flashdata('msg', 'Updated Successfully!');
}
}
我的模型NewSuppliermodel.php
public function updaterecords($name,$email,$phone,$company,$address,$sid,$city,$region,$country,$postbox)
{
$query=$this->db->query("update suppliers SET name='$name',email='$email',phone='$phone',company='$company',address='$address',city='$city',region='$region',country='$country',postbox='$postbox' where sid='".$sid."'");
return $query->result();
}
我的观点
<?php
$i=1;
foreach($data as $row)
{
?>
<form class="form" method="post" action="<?php echo base_url('app/managesupplierfull/updatesupplier/'.$row->sid) ?>">
<div class="row">
<div class="col">
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Name</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="name" value="<?php echo $row->name; ?>" required
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="example-email">Email</label>
<div class="col-lg-10">
<input type="email" id="example-email" name="email"
value="<?php echo $row->email; ?>" class="form-control" required="">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Company</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="company" value="<?php echo $row->company; ?>"
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Phone</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="phone" value="<?php echo $row->phone; ?>"
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="example-textarea">Address</label>
<div class="col-lg-10">
<textarea class="form-control" rows="5"
name="address" placeholder="" id="example-textarea"><?php echo $row->address; ?></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">City</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="city" value="<?php echo $row->city; ?>"
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Region</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="region" value="<?php echo $row->region; ?>"
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Country</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="country" value="<?php echo $row->country; ?>"
>
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label"
for="simpleinput">Post Box</label>
<div class="col-lg-10">
<input type="text" class="form-control" id="simpleinput" name="postbox" value="<?php echo $row->postbox; ?>"
>
</div>
</div>
<?php } ?>
<button type="submit" name="update" class="btn btn-primary">Update</button>
</div>
</div>
</form>
我在另一个视图中有一个表格,当我单击更新按钮时,它会打开一个新页面,并且此表单按 id 显示现有数据,当单击更新时,它应该只在当前 ID 中,但参数没有传递。
解决方案
尝试像这样更新控制器:
public function updatesupplier($sid) { // changed & removed unused parameters
if($this->input->post('update'))
{
$name=$this->input->post('name');
$email=$this->input->post('email');
$phone=$this->input->post('phone');
$company=$this->input->post('company');
$address=$this->input->post('address');
$city=$this->input->post('city');
$region=$this->input->post('region');
$country=$this->input->post('country');
$postbox=$this->input->post('postbox');
$result['data']=$this->NewSuppliermodel->updaterecords($name,$email,$phone,$company,$address,$sid,$city,$region,$country,$postbox); // added missing $sid parameter
$this->session->set_flashdata('msg', 'Updated Successfully!');
}
}
推荐阅读
- android - setBackground 到表格中的按钮
- java - 如何使用 SpEL 提取列表中对象的单个属性列表?
- python - Python Pandas:拆分和更改日期格式(一个带有例如:(2018 年 8 月 - 2018 年 11 月))和其他只有一个?
- android - 我如何确定应用程序的启动方式?
- python - Flask-Admin:发生了蓝图的名称冲突......两者共享相同的名称“admin”
- ios - 用于签署 AppStore IPA 文件的配置文件在哪里
- swift - 我有 woocommerce api 为结帐提供的 body 参数。在 alamofire 中发送参数时,我得到 400 状态码
- excel - IF 语句中的 Excel SUMIF 语句
- angular - 角度库 npm 依赖项 - 它是如何工作的?
- java - 为什么JVM在进入无限递归时不会崩溃?