Welcome Guest, Not a member yet? Register   Sign In
A Database Error
#1

[eluser]umefarooq[/eluser]
Hi
im inserting data in table it gives me following error
Quote:A Database Error Occurred

Error Number: 1048

Column 'id' cannot be null

where id is primary key when i comment var id from model it insert the data but key is always 0.
#2

[eluser]Derek Allard[/eluser]
Do you want to set that column to auto-increment?
#3

[eluser]umefarooq[/eluser]
ya id column is primary key and also auto increment but i dont know what and where is problem because first time im using CI and i want to carry on for my rest of projects. by reading the user manual its look nice.
#4

[eluser]Derek Allard[/eluser]
What does your insert code look like?
#5

[eluser]umefarooq[/eluser]
here is my model code

Code:
class FormModel extends Model {
        
        var $id;
        var $width;
        var $height;
        var $scalecontent;
        var $firstpage;
        var $alwaysopen;
        var $autoflip;
        var $fliponclick;
        var $staticshadow;
        var $dynamicshadow;
        var $movedspeed;
        var $closespeed;
        var $gotospeed;
        var $pageback;
        var $loadondemand;
        var $cachePage;
        var $cachesize;
        
        function FormModel(){
            parent::Model();
        }
        
        function insert_entry(){
            
            print_r($_POST);

            $this->width = $this->input->post('width');
            $this->height = $this->input->post('height');
            $this->scalecontent = $this->input->post('scalecontent');
            $this->firstpage = $this->input->post('firstpage');
            $this->alwaysopen = $this->input->post('alwaysopen');
            $this->autoflip = $this->input->post('autoflip');
            $this->fliponclick = $this->input->post('fliponclick');
            $this->staticshadow = $this->input->post('staticshadow');
            $this->dynamicshadow = $this->input->post('dynamicshadow');
            $this->movedspeed = $this->input->post('movedspeed');
            $this->closespeed = $this->input->post('closespeed');
            $this->gotospeed = $this->input->post('gotospeed');
            $this->pageback = $this->input->post('pageback');
            $this->loadondemand = $this->input->post('loadondemand');
            $this->cachePage = $this->input->post('cachePage');
            $this->cachesize = $this->input->post('cachesize');
            
            $this->db->insert('flipp_settings',$this);
        }
        
        
    }
#6

[eluser]Derek Allard[/eluser]
And your id is set to autoincrement? Are you sure? Could you add
Code:
echo $this->db->last_query();
after an insert and see what comes up?
#7

[eluser]umefarooq[/eluser]
with this model when i want to insert the data it give me error Column ‘id’ cannot be null but when i comment the var id than it insert the data but id is 0 always.
#8

[eluser]Derek Allard[/eluser]
And your id is set to autoincrement? Are you sure? Could you add
Code:
echo $this->db->last_query();
after an insert and see what comes up?
#9

[eluser]Seppo[/eluser]
I'll ask two questions, if you don't mind...
Can you run "DESCRIBE flipp_settings" and post the results? Are you using MySQL or other DB engine?




Theme © iAndrew 2016 - Forum software by © MyBB