This question already has answers here:
Answer
Solution:
You can try a different approach, the way you are doing will not work. Use a php variable and assign something usefull to understand that your SQL update is done, and use that variable inside the script to do the work.
Sample code below - I have used a variable $recUpdated, and modified your code, take a look.
$recUpdated = "NO";
function refresh() {
$servername = "localhost";
$username = "root";
$password = "";
$db = "wp_4lous";
$conn = new mysqli($servername, $username, $password, $db);
$checklog = mysqli_fetch_row(mysqli_query($conn, 'SELECT numero_voti FROM voti WHERE candidato="LOG"'));
if ($checklog[0] == '10') {
mysqli_query($conn, 'UPDATE voti SET numero_voti="0" WHERE candidato="LOG" AND numero_voti="10"');
$recUpdated = "YES";
}
};
?>
<script type="text/javascript">
<?php if($recUpdated == "YES") { ?>
$("#here").load(window.location.href + " #here" );
<?php } ?>
</script>
Source