I keep receiving this error.
Could not run the query: Duplicate entry '255' for key 1
I am trying to insert records into my database but it seems like my code is trying to replace the data that is already there instead of keep adding more data?
//Use explode function to put tabbed array into the variable $string.
//explode can only use strings, the foreach statement will process
//each element in the array.
foreach($listingres as $record) // $listingres is the array you got from file()
{ $record=trim($record); // Otherwise the newline character will still be on the end of the line
$fields = explode("\t", $record); // Do stuff with the $fields array.
// Insert all of the 125 different variables into database
$query = "INSERT INTO residential (mls, class, type, area, asking_price,
city, state, zip, status, sale_rent, bedrooms, fullbath, halfbath, garage,
gar_type, yr_built, sqft, counties, number_acres, agent_id, agent_name,
agent_phone, listingoffice1_id, listingoffice1_name, listingoffice1_phone,
listingagent2_id, listingagent2_name, listingagent2_phone, listingoffice2_id,
listingoffice2_name, listingoffice2_phone, comp_sa, comp_ba, year_built,
sqft_total, sqft_howmeas, lot_size, township, listing_date, expiration_date,
legal_1, legal_2, parcel, bath_upper, bath_main, bath_lower, rooms_lrsize,
rooms_lrlevel, rooms_drsize, rooms_drlevel, rooms_frsize, rooms_frlevel,
rooms_kitsize, rooms_kitlevel, beds_1size, beds_1level, beds_2size,
beds_2level, beds_3size, beds_3level, beds_4size, beds_4level, rooms_utilsize,
rooms_utillvl, rooms_description, rooms_othsize, rooms_othlvl,
other_desc, other_size, other_level, other_desc2, other_size2, other_level2,
terms, fh_flood, fh_heatbud, zoning, lock_box, subdivision, directions_1,
directions_2, original_price, assumable, accelerate, qualify, equity_amount,
assumption_payment_amount,hfyr_tax)
VALUES ($fields[0],'$fields[1]','$fields[2]','$fields[3]',$fields[4],'$fields[9]',
'$fields[10]',$fields[11],'$fields[12]',
'$fields[13]','$fields[14]','$fields[15]','$fields[16]','$fields[17]','$fields[18]',
'$fields[19]','$fields[20]','$fields[21]','$fields[22]','$fields[23]','$fields[24]',
'$fields[25]',
'$fields[26]','$fields[27]','$fields[28]','$fields[29]','$fields[30]','$fields[31]',
'$fields[32]','$fields[33]','$fields[34]','$fields[35]','$fields[36]',$fields[37],
'$fields[38]','$fields[39]','$fields[40]','$fields[41]','$fields[42]','$fields[43]',
'$fields[44]','$fields[45]','$fields[46]','$fields[47]','$fields[48]','$fields[49]',
'$fields[50]','$fields[51]','$fields[52]','$fields[53]','$fields[54]','$fields[55]',
'$fields[56]','$fields[57]','$fields[58]','$fields[59]','$fields[60]','$fields[61]',
'$fields[62]','$fields[63]','$fields[64]','$fields[65]','$fields[66]','$fields[67]',
'$fields[68]','$fields[69]','$fields[70]','$fields[71]','$fields[72]','$fields[73]',
'$fields[74]','$fields[75]','$fields[76]','$fields[77]','$fields[78]','$fields[79]',
'$fields[80]','$fields[81]','$fields[82]','$fields[83]','$fields[84]','$fields[85]',
'$fields[86]','$fields[87]','$fields[88]','$fields[89]','$fields[90]','$fields[91]')";
print $query . "<br>"; //Print out the values of the query
$result = mysql_query($query) or die('Could not run the query: '
.mysql_error()); //Run the query