Welcome Guest, Not a member yet? Register   Sign In
INSERT problem -> unknown column... [SOLVED]
#1

[eluser]victor76[/eluser]
Hi,

I got his blog post form in my View dir:
Code:
<form name="postit" action="http://localhost/codeIgniter/index.php/blog_controller/dopost" method="post">
    title: &lt;input type="text" name="title" id="title" /&gt;<br />
    comment: &lt;input type="text" name="comment" id="comment" /&gt;<br />
    &lt;input type="submit" value="send" /&gt;
&lt;/form&gt;

In my Controller I have:
Code:
function doPost()
        {
            $this->load->model('Blogmodel','',TRUE);
            
            $data['query'] = $this->Blogmodel->insert_entry();
            
        }

..And in my Model:
Code:
function insert_entry()
    {

    $this->title   = $_POST['title'];
        $this->content = $_POST['comment'];
        $this->date    = time();

        $this->db->insert('entries', $this);

    }

When I post my form, I get the error:
Quote:Error Number: 1054

Unknown column '_parent_name' in 'field list'

INSERT INTO entries (title, content, date, _parent_name, _ci_scaffolding, _ci_scaff_table) VALUES ('aaa', 'bla', 1193057963, 'Blogmodel', 0, 0)

...so, as a Newbie I can see i miss some columns in my DB (_parent_name, etc), but how can I fix my code so that it just inserts 'title','comment' and 'date'?

Best regards,
Vic


======================

I found it allready:
perhaps usefull for others...

Code:
function insert_entry()
    {
    $title   = $_POST['title'];
        $comment = $_POST['comment'];
    $aData = array('title' => $title, 'content' => $comment);
    $this->db->insert('entries', $aData);

    }

Is this the best way to insert data from a form, or is there a better way?
Best regards,

Vic
#2

[eluser]Archiloque[/eluser]
It's a bug in CI code, see http://codeigniter.com/bug_tracker/bug/2702/




Theme © iAndrew 2016 - Forum software by © MyBB