Welcome Guest, Not a member yet? Register   Sign In
UPDATE not work, PLZ Help me
#1

[eluser]Leftfield[/eluser]
Everybody Hello!
I did not clear the problem with the Update method, my simle method UPDATE does not work,and i have some problems with pass $id var into my update method , plz i need help of CI guru, thats my code:
Controller

Code:
function pageedit($id) {
        $this->load->library('common_lib');
        $this->common_lib->auth();
        $this->load->helper(array('form', 'url'));
        $this->load->library('validation');  
        $this->validation->set_rules('textfield', 'textfield', 'required');
        $this->validation->set_rules('textarea', 'textarea', 'required');    
        
//читаем запись из БД
        if (!$this->input->post('textfield') && !$this->input->post('textarea')) {
            $item = $this->Kernel->get($id);
            
            $this->validation->textfield = $item['title'];
            $this->validation->textarea = $item['fulltext'];
        }
        $data = array();
        $CI = &get;_instance();
        $title = $CI->config->item('admin_title');
        $author = $CI->config->item('admin_login');
        $data['title'] = $title;
        
        if ($this->validation->run() == FALSE) {
            $this->load->view('admin/editpage', $data);
        }
        else {
            
            $data = array(
                    'title' => $this->input->post('textfield'),
                    'fulltext' => $this->input->post('textarea'),
                    'date' => date('Y:m:d')
            );            
            $this->Kernel->update($data, $id);
            redirect('/admin/browsepages/');
        }
    }
Model
Code:
function update($data, $id) {
        $this->db->where('id', $id);
        $this->db->update('stand_alone_pages',$data);        
    }

View (Form)
Code:
<form id="form1" name="form1" method="post" action="/admin/pageedit/">
                                    <p>
                                        &lt;input name="textfield" type="text"   value="&lt;?php echo form_prep(@$this-&gt;validation->textfield)?&gt;" size="60" />
                                    </p>
                                    <p>
                                        &lt;textarea name="textarea"&gt;&lt;?php echo form_prep(@$this->validation->textarea)?&gt;&lt;/textarea&gt;
                                    </p>
                                    <p>
                                        &lt;input type="submit" name="Submit" value="Редактировать" /&gt;
                                    </p>
                                &lt;/form&gt;

Here is what I get


Quote:A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for Admin::pageedit()

Filename: controllers/admin.php

Line Number: 95
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: id

Filename: controllers/admin.php

Line Number: 128
A PHP Error was encountered

Severity: Warning

Message: Cannot modify header information - headers already sent by (output started at Z:\home\codecms\www\system\libraries\Exceptions.php:166)

Filename: helpers/url_helper.php

Line Number: 541

What am I doing wrong, tell me please ?


Messages In This Thread
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 08:57 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 09:07 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 10:00 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 10:28 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 11:42 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 11:59 AM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:16 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:40 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:46 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:50 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 01:52 PM
UPDATE not work, PLZ Help me - by El Forum - 06-12-2010, 02:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB