I followed by this IBM article http://www.ibm.com/developerworks/opensource/library/wa-codeigniter/index.html
but i receive this answer from the mysql database
Error Number: 1062
Duplicate entry '0' for key 1
INSERT INTO `guestbook` (`name`, `email`, `text`, `ipaddress`, `date`) VALUES ('assa', 'Alex', 'alex@email.com', '127.0.0.1', '2009-02-26 08:53:35')
here is a database structure
CREATE TABLE `guestbook` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(128) NOT NULL,
`email` varchar(255) NOT NULL,
`text` text NOT NULL,
`date` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
`ipaddress` varchar(32) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM;
this is Insert function:
function addContact(){
$now = date("Y-m-d H:i:s");
$data = array(
'name' => $this->input->xss_clean($this->input->post('name')),
'email' => $this->input->xss_clean($this->input->post('email')),
'text' => $this->input->xss_clean($this->input->post('notes')),
'ipaddress' => $this->input->ip_address(),
'date' => $now
);
$this->db->insert('guestbook', $data);
}
if i use id in this data array it will insert all data succsesfully, but I don’t want to care about id number - it is primary auto_increment key. How to solve problem?
