发出SOAP请求并在数据库上插入重复值

I make a soap request in php, and I get the response from request and insert the values of the response in my database. I use my browser to run the script but something strange happens when I copy the link to another tab and run it, because when I check my database the values are duplicate. Sometimes when run the script the values are not duplicate in my database at the moment, but the next day the values are duplicate, and I don't understand why.

soap_request.php

<?php
ini_set('default_charset','utf8');
$init_today = date("Y-m-d");

$xml = 'soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="http://****/definitions" xmlns:cul="http:/***/****/***">
   <soapenv:Header>'....;

$soapUrl = "https://****/Culture"; // asmx URL of WSDL

$headers = array(
  ...
  "SOAPAction: http://****/****/****/*****", 
  "Content-length: ".strlen($xml),
);

$url = $soapUrl;
// PHP cURL  for https connection with auth
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
...

$response = curl_exec($ch);
curl_close($ch);

$string = str_replace(array('ns1:', 'ns2:', 'ns3:'), array('', '', ''), $response);
$content = new SimpleXMLElement($string);

$con = mysqli_connect("localhost","root","***","*****");

function insertEventId($con, $content){

    $array_id = array();
    foreach($content->xpath('//Event') as $header){
        $result = ($header->xpath('Id'));

        $event_id = (string) $result[0];
        $sql = "INSERT INTO eventos_sapo (event_id) VALUES ('$event_id')";
        if (mysqli_query($con, $sql)) {
            echo $sql . "</br>";
            //echo "New record created successfully";
        } else {
            echo "Error: " . $sql . "<br>" . mysqli_error($con);
        }
        array_push($array_id, $event_id);

    }

    return $array_id;

}

function insertTitulo($con, $content, $array_id){
    $count = 0;
    while($count < sizeof($array_id)){
        foreach($array_id as $id){
            $count_aux = 0;
            foreach($content->xpath('//Event') as $header){
                $result = ($header->xpath('Name')); // Should output 'something'.
                if($result){
                    $titulo = (string) $result[0];
                    if($count == $count_aux){
                        $sql = "Update eventos_sapo set titulo='$titulo' where event_id='$id';";
                        mysqli_set_charset($con,"utf8");
                        if (mysqli_query($con, $sql)) {
                            echo $sql . "</br>";
                            //echo "New record created successfully";
                        } else {
                            echo "Error: " . $sql . "<br>" . mysqli_error($con);
                        }
                    }
                }
                $count_aux++;
            }
            $count++;
        }
    }
}
$array_id = insertEventId($con, $content);
insertTitulo($con, $content, $array_id);

Response of request:

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://***/**/***" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://***.****.**/***/**" xmlns:ns3="http://**.**.**/**/**">
   <SOAP-ENV:Body>
      <ns1:GetAgendaV2Response>
         <ns1:GetAgendaV2Result>
            <ns1:Events>
               <ns1:Event>
                  <ns1:Id>94343</ns1:Id>
                  <ns1:Name>Mexa-se Mais 2011 - Orientação no Jamor (BTT e Caminhada)</ns1:Name>
                  <ns1:Genre>
                     <ns1:Id>10</ns1:Id>
                     <ns1:Name>Outdoor</ns1:Name>
                  </ns1:Genre>
               </ns1:Event>
               <ns1:Event>
                  <ns1:Id>122611</ns1:Id>
                  <ns1:Name>«Memória da Politécnica: Quatro Séculos de Educação, Ciência e Cultura»</ns1:Name>
                  <ns1:Genre>
                     <ns1:Id>6</ns1:Id>
                     <ns1:Name>Exposições</ns1:Name>
                  </ns1:Genre>
               </ns1:Event>
             ....