hi everyone,
i keep on getting this error when i try to insert a value into a table via php.
Duplicate entry '' for key 2
i've tried a lot of solutions from the web including changing the the primary key from int to bigint. i also flushed the database and deleted all entries from the database but i still got that error. i could insert records from the nysql command prompt but not from the php script.
does anyone know what might be wrong?
the table in question looks like this:
CREATE TABLE `article_fields` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`field_title` VARCHAR(75) NOT NULL,
`field_type` VARCHAR(75) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=INNODB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
and my php code to insert data into the table looks like this:
$sql = 'INSERT INTO article_fields VALUES("NULL","'.$new_text.'","'.$field_type.'")';
$insert = mysql_query($sql) or die(mysql_error());
Last edited by peter_budo; Nov 20th, 2008 at 12:42 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.