Jump to content


Photo

Duplicate entry '127' for key 1


  • This topic is locked This topic is locked
2 replies to this topic

#1 Nrees87

Nrees87
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 July 2006 - 06:44 PM

Hi guys, I have a gallery page, that has been working fine for several months now. But all of a sudden when I try and add a new image with the following PHP code:

$imgquery = mysql_query("INSERT INTO mlc_gallery (ItemID,Title,Description,File,Category)". "VALUES ('NULL', '" . $capt . "', '" . $descr . "','". $_FILES['file']['name'] ."', '" . $gallerycat . "')") or die(mysql_error());

I get the following error:

Duplicate entry '127' for key 1

The table layout is as follows(information shown is from export table option in MySQL Admin):

CREATE TABLE `mlc_gallery` (
  `ItemID` tinyint(4) NOT NULL auto_increment,
  `Title` varchar(50) NOT NULL default '',
  `Description` text NOT NULL,
  `File` text NOT NULL,
  `Category` tinyint(1) NOT NULL default '0',
  PRIMARY KEY  (`ItemID`)
) TYPE=MyISAM PACK_KEYS=0 AUTO_INCREMENT=127 ;

I have tried changing the AUTO_INCREMENT value to 128 to overcome this problem, but it stays on 127.

Any help is greatly appreciated.

Nathan Rees


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 17 July 2006 - 06:47 PM

You'll need to change from the tinyint definition (which has a limit of +127) to smallint or any number field that accepts larger values.
Legend has it that reading the manual never killed anyone.
My site

#3 Nrees87

Nrees87
  • New Members
  • Pip
  • Newbie
  • 5 posts

Posted 17 July 2006 - 07:16 PM

AndyB, thanks a lot, problem solved.

Nathan Rees




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users