I have a txt
file that I am extracting information and in it the information is repeated 6 times, which inserts me in the database the same record also 6 times.
Sete UNIQUE
to a unique number for each record in the mysql database but when trying to run the sql that inserts the data, it gives Entrada '120000001016' duplicada para a chave 'SQ_CANDIDATO'
and the insertion process is finished.
How could I solve this problem by inserting only once each record in the database without having to treat txt
?
foreach ($itens as $item) {
$dados = explode(';', $item);
mysql_query("INSERT INTO VOT_CAND_MUN_ZONA VALUES (
'',
'".utf8_decode(trim($dados[0], '"'))."',
'".utf8_decode(trim($dados[1], '"'))."',
'".utf8_decode(trim($dados[2], '"'))."',
'".utf8_decode(trim($dados[3], '"'))."',
'".utf8_decode(trim($dados[4], '"'))."',
'".utf8_decode(trim($dados[5], '"'))."',
'".utf8_decode(trim($dados[6], '"'))."',
'".utf8_decode(trim($dados[7], '"'))."',
'".utf8_decode(trim($dados[8], '"'))."',
'".utf8_decode(trim($dados[9], '"'))."',
'".utf8_decode(trim($dados[10], '"'))."',
'".utf8_decode(trim($dados[11], '"'))."',
'".utf8_decode(trim($dados[12], '"'))."', <---- UNIQUE
'".utf8_decode(trim($dados[13], '"'))."',
'".utf8_decode(trim($dados[14], '"'))."',
'".utf8_decode(trim($dados[15], '"'))."',
'".utf8_decode(trim($dados[16], '"'))."',
'".utf8_decode(trim($dados[17], '"'))."',
'".utf8_decode(trim($dados[18], '"'))."',
'".utf8_decode(trim($dados[19], '"'))."',
'".utf8_decode(trim($dados[20], '"'))."',
'".utf8_decode(trim($dados[21], '"'))."',
'".utf8_decode(trim($dados[22], '"'))."',
'".utf8_decode(trim($dados[23], '"'))."',
'".utf8_decode(trim($dados[24], '"'))."',
'".utf8_decode(trim($dados[25], '"'))."',
'".utf8_decode(trim($dados[26], '"'))."',
'".utf8_decode(trim($dados[27], '"'))."',
'".utf8_decode(trim($dados[28], '"'))."'
)") or die (mysql_error());