My situation is as follows , I have a whole email marketing system in PHP and emails are added by .CSV file, however it is adding duplicate values and blank values.
The problem is that , I have 1 table callsn_emails
with 2 columns, one called ativo
and another email
, the ativo
column has and should have duplicate values, because it will be the one that will say if the email is active or not, that is, in almost every email the value of the ativo
column will be s
. The only part I want to forbid duplicate values will be in the email
column.
In short, I need to block only duplicate emails and emails in the end, after adding the .CSV file, the system shows the count of added records and records not added if duplicate emails).
Code where you add your emails looks like this:
}
$tabela = "n_emails";
$arquivo = 'addemail/x234gqq.csv';
$arq = fopen($arquivo,'r');
while(!feof($arq))
for($i=0; $i<1; $i++){
if ($conteudo = fgets($arq)){
$ll++; // $ll
$linha = explode(';', $conteudo);//
}
$sql = "INSERT INTO $tabela (ativo, email) VALUES
('$linha[0]', '$linha[1]')";
$result = mysql_query($sql) or die(mysql_error());
$linha = array();
}
echo "Quantidade de Emails Adicionados: ".$ll;
echo "<br><a href='..'>Clique aqui para voltar</a>";
?>