Incorrect integer value: '' for column 'id' at row 1 |
[eluser]rochellecanale[/eluser]
help i got this error when i try to insert a new item in my table. my form: ========================================================================================== <div class="main"> <div class="main-content"> <h1 class="block">MEMBERSHIP LOGIN</h1> <div class="column1-unit"> <h1>Create Free Account Now</h1> <div class="loginform"> <?php echo form_open('homepage/addNewMember'); ?> <fieldset> <p><label class="top">Reffered By:</label><br /> <input type="text" name="reffered" tabindex="1" class="field" value="" placeholder="Reference Username" /> </p> <p><label class="top">Username:</label><br /> <input type="text" name="username" tabindex="1" class="field" value="" placeholder="Desired Username" /> </p> <p><label class="top">Last Name</label><br /> <input type="text" name="lastname" tabindex="2" class="field" value="" placeholder="Your Last Name" /> </p> <p><label class="top">First Name:</label><br /> <input type="text" name="firstname" tabindex="1" class="field" value="" placeholder="Your First Name" /> </p> <p><label class="top">Middle Name:</label><br /> <input type="text" name="middlename" tabindex="1" class="field" value="" placeholder="Your Middle Name" /> </p> <p><label class="top">Email Address:</label><br /> <input type="text" name="email" tabindex="1" class="field" value="" placeholder="[email protected]" /> </p> <p><label class="top">Mobile Number:</label><br /> <input type="text" name="contact" tabindex="1" class="field" value="" placeholder="xxxx-xxx-xxxx" /> </p> <p><label class="top">Gender: </label><br /> <select name="gender"> <option value="">---</option> <option value="Male">Male</option> <option value="Female">Female</option> </select> </p> <p><label class="top">Password: </label><br /> <input type="password" name="password" tabindex="1" class="field" value="" placeholder="8 to 16 characters only" /> </p> <p><label class="top">Confirm Password: </label><br /> <input type="password" name="passcon"tabindex="1" class="field" value="" placeholder="Re-type password" /> </p> <p><input type="submit" name="cmdweblogin" class="button" value="CREATE" /></p> </fieldset> </form> </div> </div> </div> ========================================================================================== my controller method public function addNewMember(){ $this->homepagemodel->addNewMember(); $this->load->view('sites/success'); } ========================================================================================== my model method public function addNewMember(){ $data = array( 'id' => '', 'username' => strtolower($this->input->post('username')), 'lastname' => ucwords($this->input->post('lastname')), 'firstname' => ucwords($this->input->post('firstname')), 'middlename' => ucwords($this->input->post('middlename')), 'gender' => $this->input->post('gender'), 'email_address' => strtolower($this->input->post('email')), 'mobile_number' => $this->input->post('contact'), 'reffered_by' => $this->input->post('reffered'), 'password' => md5($this->input->post('password')), 'date_registered' => date('Y-m-d h:i') ); return $this->db->insert('tbl_member',$data); } ========================================================================================== my table structure CREATE TABLE tbl_member( id int unsigned auto_increment, username varchar(50) unique not null, lastname varchar(50) not null, firstname varchar(50) not null, middlename varchar(50) not null, gender enum('Male','Female'), email_address varchar(50) not null, mobile_number int not null, reffered_by varchar(50), password varchar(50) not null, date_registered datetime );
[eluser]CroNiX[/eluser]
You're trying to insert an empty string into an integer column. The ID is an auto-increment column that will populate itself, so leave the ID out of the insert.
[eluser]CroNiX[/eluser]
No problem. Next time, please put your code in code tags like my sig shows so it will be easier to read. |
Welcome Guest, Not a member yet? Register Sign In |