• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Upload Error

#1
Hello,
What am I doing wrong?
I get this error message.
Quote:An uncaught Exception was encountered
Type: ArgumentCountError
Message: Too few arguments to function Admin_model::insert_produckt(), 0 passed in H:\xampp\htdocs\newKARTENLISTE\test2\application\controllers\Admin.php on line 1007 and exactly 1 expected
Filename: H:\xampp\htdocs\newKARTENLISTE\test2\application\models\Admin_model.php
Line Number: 1157
Backtrace:
File: H:\xampp\htdocs\newKARTENLISTE\test2\application\controllers\Admin.php
Line: 1007
Function: insert_produckt
File: H:\xampp\htdocs\newKARTENLISTE\test2\index.php
Line: 315
Function: require_once


Controller:
PHP Code:
            public function insert_produckt()
                {
                    
$produckt_name $this->input->post('add_produckt_name');
                    
$config['upload_path'] = './assets/images/produckt/';
                    
$config['allowed_types'] = '*';
                    
$config['max_size'] = '2048';
                    
$config['max_width'] = '2000';
                    
$config['max_height'] = '2000';
                    
$this->load->library('upload'$config);
                    if (!
$this->upload->do_upload())
                        {
                            
$errors = array('error' => $this->upload->display_errors());
                            
$post_image 'noimage.jpg';
                        }
                    else
                        {
                            
$data = array('upload_data' => $this->upload->data());
                            
$post_image $produckt_name;
                        }
                    
$this->Admin_model->insert_produckt();
                    
redirect('admin/produckt_add/');
                } 

Model:
PHP Code:
            public function insert_produckt($post_image)
                {
                    
$image_data $this->upload->data();
                    
// $this->db->where('tb_produckt_name', $this->input->post('add_produckt_name'));
                    // $this->db->where('tb_produckt_bereich', $this->input->post('add_karten_name_en'));
                    // $this->db->where('tb_produckt_bereich_id', $this->input->post('add_karten_name_en'));
                    // $result = $this->db->get('db_produckt');
                    // if($result->num_rows() < 1)
                        // {
                            
$data = array(    'tb_produckt_name' => $this->input->post('add_produckt_name'),
                                            
'tb_produckt_file_name' => $image_data['raw_name'],
                                            
'tb_produckt_file_typ' => $image_data['image_type'],
                                            
'tb_produckt_bereich' => $this->input->post('add_produckt_bereich'),
                                            
'tb_produckt_bereich_id' => $this->input->post('add_produckt_bereich_id'),
                                            );
                            return 
$this->db->insert('db_produckt'$data);
                        
// }
                


View:
Code:
<?php echo validation_errors(); ?>
<?php echo form_open('Admin/insert_produckt'); ?>
<div class="col-md-3">
    <div class="form-group">
        <h4><label class="label label-success">Name</label></h4>
            <input type="text" class="form-control" name="add_produckt_name" maxlength="255">
    </div>
</div>
<div class="col-md-3">
    <div class="form-group">
        <h4><label class="label label-success">Rarität</label></h4>
            <div class="input-group">
                <select class="form-control" name="add_produckt_bereich">
                    <option value="">----</option>
                    <option value="1">Haupt</option>
                    <option value="2">Sub</option>
                    <option value="3">Sub-Sub</option>
                </select>
                <div class="input-group-addon"></div>
                <select class="form-control" name="add_produckt_bereich_id">
                    <option value="">----</option>
<?php foreach ($produckt_selects as $produckt): ?>
                    <option value="">----</option>
<?php endforeach; ?>
                </select>
            </div>
    </div>
</div>
<div class="col-md-3">
    <div class="form-group">
        <h4><label class="label label-success">Upload</label></h4>
            <input type="file" name="userfile" size="20">
    </div>
</div>
<div class="col-md-3">
    <div class="form-group">
        <h4><label class="label label-success">Optionen</label></h4>
            <button class="btn btn-danger" type="submit">Senden</button>
    </div>
</div>
</form>
Reply

#2
You have used this in your controller:

PHP Code:
$this->Admin_model->insert_produckt(); 

But in your model you have this:

PHP Code:
public function insert_produckt($post_image

Hence, too few arguments. i.e. You have not set the $post_image argument.

Hope that helps,

Paul.
Reply

#3
If you want to use it with or without a parameter, then do this.

PHP Code:
insert_produckt($post_image null); 
What did you Try? What did you Get? What did you Expect?

Joined the CodeIgniter Community in 2009.          ( Skype: insitfx )
Reply

#4
Thanks
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.