Sweetalert2 not showing in the code, but show in the console

i’m using sweetalert2 for my code, it not works when i use in my code. So, i test the script on the inspect element console on my app. And it works. Anyone can help?

$query = mysqli_query($koneksi,"SELECT `name` FROM `tb_bengkel` WHERE `name` = '$name'");
if(mysqli_num_rows($query) == true)
{
"<script>
var Toast = Swal.mixin({
    toast: false,
    position: 'center',
    showConfirmButton: false,
    timer: 2000
  });
Toast.fire({
    icon: 'error',
    title: 'Name has been used!'
  })
  </script>";
}