Telegram duplicating messages

0

I'm facing a problem with a Telegram API encoding. Messages are working normally, but they are all coming in duplicate, what can they be?

Follow function:

function sendMessage($chatID, $messaggio, $token) {
    $url = "https://api.telegram.org/" . $token . "/sendMessage?chat_id=" . $chatID;
    $url = $url . "&text=" . urlencode($messaggio);
    $ch = curl_init();
    $optArray = array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true
    );
    curl_setopt_array($ch, $optArray);
    $result = curl_exec($ch);
    curl_close($ch);

Follow the call:

$token = "bot******************";
$chatid = "***********";
sendMessage($chatid,"mensagem aqui!", $token);  

I read something about offset, but I do not know how to start implementing this in code ... If anyone can help me, I'm grateful!

---- update ----- Follows while from fatch_assoc where there is the sending function + sendMessage

$result_alerta = mysql_query( $query_alerta );
    while ( $row_alerta = mysql_fetch_assoc( $result_alerta ) ) 
        {     funções aqui     }

---- update ----- follow query result link

    
asked by anonymous 02.03.2018 / 19:20

1 answer

0

In your query, if you do not group the data, you may have duplicate rows.

SELECT alerta.nr_celular nr_celular,
    setor.nm_setor    nm_setor,
    alerta.ds_email ds_email,
    cliente.nm_cliente nm_cliente
    FROM
    tbl_setor setor,
    tbl_setor_usuario set_usuario,
    tbl_alerta_contato alerta,
    tb_usuarios usuario,
    tbl_cliente cliente
    WHERE
    set_usuario.cd_setor = setor.cd_setor
    and cliente.cd_cliente = setor.cd_cliente
    and set_usuario.cd_usuario = alerta.cd_usuario
    and set_usuario.cd_cliente = alerta.cd_cliente
    and set_usuario.cd_setor = alerta.cd_setor
    and usuario.cd_usuario = set_usuario.cd_usuario    
    and setor.sn_alerta = 'S'
    and usuario.usr_ativo = 'S'
    AND setor.cd_cliente = $cliente (variável do login do usuário por post)
    AND setor.cd_setor = $setor (variável do login do usuário por post)
GROUP BY alerta.cd_usuario # coluna para agrupar!
    
05.03.2018 / 20:24