Welcome Guest, Not a member yet? Register   Sign In
Insert Date in database[SOLVED]
#1

[eluser]Ivar89[/eluser]
I can't seem to insert my Date in the database.
Model:
Code:
function Insert_Publish($data)
    {
        $ID_Page = $_POST['ID_Page'];
        
        if(isset($data['Publish_date']))
        $this->db->set('Publish_date',$data['Publish_date']);    
        
        $this->db->where('ID_Page',$ID_Page);
        $query = $this->db->update('tblpage');
        return $ID_Page;
    }

Controller:
Code:
function check()
    {
        $id['ID_Page'] = $this->insert_model->Insert_Publish($_POST);
        $this->load->view('page/check', $id, FALSE);
    }

view:
Code:
<?php echo form_open ('page/check') ?>
            
                            <p id="Publish">&lt;input type="radio"&gt;Publish</p>
                            &lt;?php
                                $this->load->helper('date');
                                $datestring = "%Y-%m-%d";
                                $time = time();
                            ?&gt;
                            <p id="Pdate" style="display:none;">Publication Date:</p>
                            <p>&lt;input style="display:none;" type="text" class="date" name="Publish_date" value="&lt;?php echo mdate($datestring, $time);?&gt;" id="Date"&gt;&lt;/p>
                            &lt;input type="hidden" name="ID_Page" value="&lt;?php echo $ID_Page ?&gt;" /&gt;
                            &lt;input type="image" src="/public/img/button.jpg" class="btn" value="next" /&gt;
                        &lt;/form&gt;

I use the exact same code for a different page and it DOES work there...
All names are checked on capitalt and spelling.
He just does NOT insert it in the database...
btw: it is updating because I multiple steps for making one row in the database.
#2

[eluser]theshiftexchange[/eluser]
You should try debugging the code and seeing if the date variable is passed to the model or not.

I.e use var_dump($data); in the model and see what data, if any, is passed to the model. If the date is not passed, then the issue is in the view. If the date is passed, then the issue is in the model. Help narrow down the issue
#3

[eluser]Ivar89[/eluser]
well data IS being passed so it is in the model but still I don't see anything wrong in the modelTongue
#4

[eluser]Ivar89[/eluser]
I fixed it, I made a mistake at previous step and I didn't post the ID_Page the right way so he always got ID_Page = 1...

fixed now




Theme © iAndrew 2016 - Forum software by © MyBB