Good afternoon I'm finalizing a script that will make some updates on our site I have an array that in the beginning contains all the clients of the company and as the script is run, some are removed. In the end, the remaining customers in the array must be updated with the INACTIVE Status on our site. The problem is that some records left in this array are returning this error message.
Follow the code snippet -
echo "Existem ".count($array_codigos) . " registros no banco SQL<br>";
arsort($array_codigos);
for($iy = 0; $iy <= count($array_codigos); $iy++){
$num++;
/******************************************************************
* Deleta os clientes inexistentes do banco DBF do banco SQL *
* Tabelas: Clientes, Contratos, Pagamentos, Boletos e Usuários *
******************************************************************/
$codigo_cliente = $array_codigos[$iy];
// TABELA CLIENTE
$consulta_cli = mysql_query("SELECT * FROM clientes WHERE cod_cliente = '$codigo_cliente'");
$num_cli = mysql_num_rows($consulta_cli);
if($num_cli != 0){
$array_cli = mysql_fetch_array($consulta_cli);
$status = $array_cli['status_cli'];
$nome_cliente = $array_cli['nome_cliente'];
if($status_cli != 'I'){
$update_inativo = mysql_query("UPDATE clientes SET status_cli = 'I' WHERE cod_cliente = $codigo_cliente");
if($update_inativo){
$inativos++;
echo "$iy - $codigo_cliente - $nome_cliente não existe no DBF - Atualizado para Inativo<br>";
$delete_users = mysql_query("DELETE FROM usuarios WHERE cod_cliente = $codigo_cliente");
}else{
$erro = mysql_error();
echo "$erro";
}
}
}
}
The code is very long, if necessary, put other information.
Thank you in advance.