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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.