Welcome Guest, Not a member yet? Register   Sign In
Insert/Edit text problem with database
#1

[eluser]faxtion[/eluser]
Either I am being stupid or something is wrong.

I have a simple CRUD system working and have just noticed that when I add or edit and entry the text I entered in the textarea gets trimmed, but if I enter it directly into db through phpmyadmin it works and shows up in edit form.

My db field thats taking the textarea is set to text, and I am only use one validation rule on the form to check if a title has been entered

Anyone got any ideas?
#2

[eluser]slowgary[/eluser]
Maybe. Post your code something. Is your text getting truncated to the same length every time? What is the text? Is it all text getting truncated, or just certain text?
#3

[eluser]faxtion[/eluser]
View
Code:
<?php echo validation_errors(); ?>

<?php
    $attributes = array('class' => 'email', 'id' => 'myform');
    echo form_open('admin/add/', $attributes);
?>
<h5>Title</h5>
&lt;input type="text" name="title" value="" size="50" /&gt;

<h5>Body</h5>
&lt;textarea name="body"&gt;
&lt;/textarea&gt;
<h5>Excerpt</h5>
&lt;textarea rows="2" cols="38" name="excerpt"&gt;
&lt;/textarea&gt;

<h5>Image</h5>
&lt;input type="text" name="image" value="" size="50" /&gt;

<div>&lt;input type="submit" value="Submit" /&gt;&lt;/div>

&lt;/form&gt;

Controller

Code:
function add() {
        
        $this->load->helper(array('file','form','url'));    
        $this->load->library('form_validation');

        $this->load->model('Modeladmin', '', TRUE);
        
        $this->form_validation->set_rules('title', 'Title', 'required');
        
        if ($this->form_validation->run() == TRUE) {
            $article_data = $this->Modeladmin->add_article();
            redirect('/admin/','refesh');
        } else {
            $this->load->view('admin/add');
        }
   }

Model

Code:
function add_article() {
        $article_data = array(
               //'id' => $this->input->post('id'),
               'title' => $this->input->post('title'),
               'body' => $this->input->post('body'),
               'excerpt' => $this->input->post('excerpt'),

          );
        $this->db->insert('articles', $article_data);
    }
#4

[eluser]TheFuzzy0ne[/eluser]
How many characters is the text field being truncated to?
#5

[eluser]faxtion[/eluser]
For some reason it is not doing it now, have not changed anything, but have fully tested adding different amounts of text and it does the truncate any text what so ever




Theme © iAndrew 2016 - Forum software by © MyBB