Welcome Guest, Not a member yet? Register   Sign In
What is wrong with my insert
#1

[eluser]Mohammed Zayan[/eluser]
I use this code in the view file
Code:
<br />
<div class="cblock">
    &lt;?php  
    $id = $this->uri->segment(3);
    if(isset($message)){
        echo "<h3>" . $message . "</h3>";
    }
    ?&gt;
    <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>
            <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;
                </select>
            </td>
        </tr>
        <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>
        </tr>
        </table>
        <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;
    </div>
</div>

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

and this is the code in cats_model
Code:
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);
        if($sql){
            return TRUE;
        }
    }

and this is the code in languages_model
Code:
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
http://im28.gulfup.com/2012-05-05/1336223191601.jpg
it add 4 rows contan zeros after my insert
I don't know what is wrong.
So, someone tell me please.
#2

[eluser]vrencianz[/eluser]
Maybe this issue is related to this one http://ellislab.com/forums/viewthread/216788/, check your error logs.




Theme © iAndrew 2016 - Forum software by © MyBB