Jump to content

updating issue


spearchilduser

Recommended Posts

HI there im having a problem with updating one table with anopther tables contents atm i have this code:

if($sql)
{
       $msg = "Taxi Accepted sucessfully.";
       mysql_query("INSERT INTO user_location ( User_ID,User_Longitude,User_Latitude) SELECT User_ID,User_Longitude,User_Latitude FROM quotes") or die (mysql_error());
}
       else
       {
$msg = "Taxi not Accepted sucssfully try again.";
echo "$msg";
       }

 

The error message im getting is :Duplicate entry '1' for key 1

 

:S any help at all

 

Thank You

Link to comment
https://forums.phpfreaks.com/topic/259325-updating-issue/
Share on other sites

Table Create Table

quotes CREATE TABLE `quotes` (\n `Quote_ID` int(11) NOT NULL auto_increment,\n `User_ID` int(11) NOT NULL,\n `Firm_By_Customer` int(11) NOT NULL,\n `Firm_ID` int(11) NOT NULL,\n `Customer_Location` varchar(255) NOT NULL,\n `User_Longitude` varchar(50) NOT NULL,\n `User_Latitude` varchar(50) NOT NULL,\n `Customer_Destination` varchar(255) NOT NULL,\n `How_Many` int(11) NOT NULL,\n `Wait_Time` int(11) NOT NULL,\n `Price` int(11) NOT NULL default '0',\n `accept_Decline` tinyint(1) NOT NULL default '5',\n `DeclienedByCustomer` tinyint(1) NOT NULL default '5',\n `Time` time NOT NULL,\n `Date` date NOT NULL,\n PRIMARY KEY (`Quote_ID`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1

 

 

user_location CREATE TABLE `user_location` (\n `User_ID` int(50) NOT NULL,\n `User_Longitude` varchar(50) NOT NULL,\n `User_Latitude` varchar(50) NOT NULL,\n `User_Time` varchar(50) NOT NULL,\n `User_Date` varchar(50) NOT NULL,\n PRIMARY KEY (`User_ID`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1

 

is the full message

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/259325-updating-issue/#findComment-1329360
Share on other sites

user_location CREATE TABLE `user_location` (\n `User_ID` int(50) NOT NULL,\n `User_Longitude` varchar(50) NOT NULL,\n `User_Latitude` varchar(50) NOT NULL,\n `User_Time` varchar(50) NOT NULL,\n `User_Date` varchar(50) NOT NULL,\n PRIMARY KEY (`User_ID`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1
You do have a primary key in your user_location table (as indeed you should) - I have highlighted it in red above -, please follow the link I provided previously to find out how to properly handle this issue.
Link to comment
https://forums.phpfreaks.com/topic/259325-updating-issue/#findComment-1329362
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.