Welcome Guest, Not a member yet? Register   Sign In
array session didn't work
#1

[eluser]yudahebat[/eluser]
I have a controller
Code:
function v_cart()
    {
        $data['css']         = $this->css;
        $data['base']         = $this->base;
        $data['menu_web']     = $this->menu;
        $data['myrobots']     = '<meta name="robots" content="noindex,nofollow">';
        $data['mywebtitle'] = 'mrputucar | Your cart';
        
        $this->output->enable_profiler(TRUE);
        $this->session->set_userdata(array('nama' => $this->input->post('nama'),'photo' => $this->input->post('photo'),'harga' => $this->input->post('harga'),'renttgl' => $this->input->post('renttgl'),'rettgl' => $this->input->post('rettgl')));
    
        $this->load->view('v_cart',$data);
    }

and view

Code:
<?php echo form_open('mrputucar/update_cart'); ?>
                <table width="645" border="0" cellpadding="0" cellspacing="0" class="tabel" >
                <tr>
                    <td width="130" class="tabel" align="center"><p>Car Type</p></td>
                    <td width="110" class="tabel" align="center"><p>Rent date</p></td>
                    <td width="110" class="tabel" align="center"><p>Return date</p></td>
                    <td width="80" class="tabel" align="center"><p>Duration</p></td>
                    <td width="100" class="tabel" align="center"><p>Price/day</p></td>
                    <td width="110" class="tabel" align="center"><p>Suhtotal</p></td>
                </tr>
                &lt;?php $query = $this->session->userdata();
                $user_array = $query->result_array();
                if(count($user_array) > 0)
                    {
                        foreach($user_array as $ua)
                        { ?&gt;
                <tr>
                    <td width="130" class="tabel"><p>&lt;?= $ua['nama'];?&gt;</p></td>
                    <td width="110" class="tabel"><p>&lt;?= $ua['renttgl'];?&gt;</p></td>
                    <td width="110" class="tabel"><p>&lt;?= $ua['rettgl'];?&gt;</p></td>
                    <td width="80" class="tabel"><p>&lt;?= (strtotime($this->session->userdata('rettgl')) - strtotime($this->session->userdata('renttgl'))) / 86400;?&gt; day</p></td>
                    <td width="100" class="tabel"><p>$ &lt;?= $ua['harga'];?&gt;</p></td>
                    <td width="110" class="tabel"><p>$ &lt;?= ((strtotime($this->session->userdata('rettgl')) - strtotime($this->session->userdata('renttgl'))) / 86400) * $this->session->userdata('harga');?&gt;</p></td>
                </tr>
                <tr>
                    <td colspan="4" class="tabel2"><p>&lt;?php echo form_submit('', 'send request'); ?&gt;</p></td>
                    <td  class="tabel2"><p>Total</p></td>
                    <td  class="tabel2"><p>$...</p></td>
                </tr>
                    &lt;?php }
                    } ?&gt;
                    
                </table>
                    &lt;?php echo form_close(); ?&gt;

when I run it, the array didn't work
its error
Code:
A PHP Error was encountered

Severity: Warning

Message: Missing argument 1 for CI_Session::userdata(), called in C:\xampp\htdocs\CI2\system\application\views\v_cart.php on line 22 and defined

Filename: libraries/Session.php

Line Number: 420
Code:
A PHP Error was encountered

Severity: Notice

Message: Undefined variable: item

Filename: libraries/Session.php

Line Number: 422
Code:
Fatal error: Call to a member function result_array() on a non-object in C:\xampp\htdocs\CI2\system\application\views\v_cart.php on line 23

line 23 :
Code:
$user_array = $query->result_array();

whats wrong? I just wanna show my session on array. so every I input data from another views it will show as a session without replace last entry data
looks like cart system...


Messages In This Thread
array session didn't work - by El Forum - 06-17-2009, 07:27 PM
array session didn't work - by El Forum - 06-17-2009, 07:29 PM
array session didn't work - by El Forum - 06-17-2009, 07:30 PM
array session didn't work - by El Forum - 06-18-2009, 12:10 AM
array session didn't work - by El Forum - 06-18-2009, 12:37 AM
array session didn't work - by El Forum - 06-18-2009, 12:46 AM
array session didn't work - by El Forum - 06-18-2009, 12:50 AM
array session didn't work - by El Forum - 06-19-2009, 01:36 AM
array session didn't work - by El Forum - 06-19-2009, 02:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB