CodeIgniter Forums

Full Version: What is wrong with my insert
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Mohammed Zayan[/eluser]
I use this code in the view file
<br />
<div class="cblock">
    $id = $this->uri->segment(3);
        echo "<h3>" . $message . "</h3>";
    <div class="headmenu">Add Translation</div>
    <div class="bodymenu">
        &lt;?php echo form_open("cats/add_cat_translation/$id"); ?&gt;
        <table class="tabl">
            <tr class="a">
            <td>&lt;?php echo form_label('Language: ', 'language'); ?&gt;</td>
                <select name="language">
                    &lt;?php foreach($rows as $row){ ?&gt;
                    <option value="&lt;?php echo $row-&gt;id; ?&gt;">&lt;?php echo $row->description; ?&gt;</option>
                    &lt;?php } ?&gt;
        <tr class="b">
            <td>&lt;?php echo form_label('Catg Name: ', 'name'); ?&gt;</td>
            &lt;?php $data = array('name' => 'name', 'id' => 'name', 'size' => 40, 'value' => set_value('name')); ?&gt;
            <td>&lt;?php echo form_input($data); ?&gt;</td>
        <br />
    &lt;input type="submit" name="submit" class="buton" value="Save" /&gt;&nbsp;&nbsp;
    <a href="&lt;?php echo base_url(); ?&gt;cats/cats_" class="links">Back</a>
        &lt;?php echo form_close(); ?&gt;

And this is the controller code
function add_cat_translation(){
        $query = $this->cats_model->addCatTranslation();
            $data['message'] = 'Added!';
            $q = $this->languages_model->getLangData();
                $data['results'] = $q;
            $data['main_content'] = 'cats/add_translation_view';
            $this->load->view('includes/template', $data);

and this is the code in cats_model
function addCatTranslation(){
        $data = array(
            'id'          => NULL,
            'book_cat_id' => $this->uri->segment(3),
            'language_id' => $this->input->post('language'),
            'description' => $this->input->post('name')
        $sql = $this->db->insert('book_cat_translation', $data);
            return TRUE;

and this is the code in languages_model
function getLangData(){
        $sql = "SELECT `id`, `description` FROM `language`";
        $query = $this->db->query($sql);
        if($query->num_rows > 0){
            return $query->result();

when I add a translation in book_cat_translation table I have this result at the photo
it add 4 rows contan zeros after my insert
I don't know what is wrong.
So, someone tell me please.

El Forum

Maybe this issue is related to this one, check your error logs.