Duplicate keys...

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



	OK, I cannot figure out why I keep getting errors about "Duplicate
entry for key 1".  Someone please come to my rescue here as this is truly
kicking my but.

if ($dateDiff == 2) {
	mysql("$DBName","INSERT INTO phpCalendar_Details VALUES (
	'$said','Comp day for weekend
On-Call','','','','','','','','','',2,'$CalendarDetailsID')") or
die(mysql_error());
			
	mysql("$DBName","UPDATE Balances SET CompEarned=CompEarned+8,
CompTaken=CompTaken+8 WHERE said='$said'") or die(mysql_error());
	$result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM
phpCalendar_Details") or die(mysql_error());
		while ($row = mysql_fetch_row($result)) {
		$CalendarDetailsID = $row[0];
		}
	mysql("$DBName","INSERT INTO Log VALUES(
	'$entryid','$said','Comp',DATE_ADD('$StopDate',INTERVAL 1
DAY),'Y','','Awarded for weekend On-Call','8','$CalendarDetailsID')") or
die(mysql_error());
			
	mysql("$DBName","INSERT INTO phpCalendar_Daily VALUES(
	DATE_ADD('$StopDate',INTERVAL 1 DAY),'',1,2,'$CalendarDetailsID')")
or die(mysql_error());
}
		
if ($dateDiff < 0) {
commonHeader($glbl_SiteTitle);
echo "<center><font color=\"red\"><b>Your END DATE COMES BEFORE YOUR START
DATE. Please complete the form below.</b></font></center><p>\n\n";

} elseif ($Stop != 1) {
		
if ($CalendarDetailsID) {
	$CalendarDetailsID = $CalendarDetailsID + 1;
} else {
	$result = mysql("$DBName","SELECT LAST_INSERT_ID() FROM
phpCalendar_Details") or die(mysql_error());
	while ($row = mysql_fetch_row($result)) {
	$CalendarDetailsID = $row[0];
	}
}
		
mysql("$DBName","INSERT INTO phpCalendar_Details VALUES (
'$said','On-Call for $StartDate to
$StopDate','','','','','','','','','',1,'$CalendarDetailsID')") or
die(mysql_error());
					
mysql("$DBName","INSERT INTO phpCalendar_Daily VALUES(
'$StartDate','$StopDate','1','1','$CalendarDetailsID')") or
die(mysql_error());

	This is the only place in the script that is attempting to enter
data into the CalendarDetailsID field.  This is the auto_increment field
that is having problems, I think.  The other strange part of this is that
thedata in the auto_increment field has two separate ranges (10 - 40 with
gaps, and 70 - 78 with gaps).  I have been doing a lot of adding and
removing of data to test during development, but I thought an auto_increment
field would still track and deal with this correctly.
	Thank again for the help.

Scott Nipp
Phone:  (214) 858-1289
E-mail:  sn4265@sbc.com
Web:  http:\\ldsa.sbcld.sbc.com



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux