Question: Can I have an if\_php\_statement before the `or die()` statement?

My code is something like this:

```
<?php
    $var=mysqli_query($db, $sql)

    if($var){

    echo"<img id='success' src='success.jpg'>
    <script>
    $('#success').fadeIn();
    $('#success').fadeOut(1000);
    </script>";
    }
    else
    {
    echo"<img id='failure' src='failure.jpg'>
    <script>
    $('#failure').fadeIn();
    $('#failure').fadeOut(1000);
    </script>";
    }

    or die("Error");
?>

```

I am trying to appear an image for a while in case of success or failure before the or die statement is executed. I tried but without success. Is there anything alternative and similar to that?

Answer: 
First replace the double quotes with single quotes or escape it `\"`, and you missed the semicolon after `mysqli_query()`

I don't know what you exactly want but if you want to echo something before your die() comes, you can do it like this:

```
$var= mysqli_query($db, $sql);

if( $var ){
echo"<img id='success' src='success.jpg'>
<script>
$('#success').fadeIn();
$('#success').fadeOut(1000);
</script>";
} else {
echo"<img id='failure' src='failure.jpg'>
<script>
$('#failure').fadeIn();
$('#failure').fadeOut(1000);
</script>";
die( "Error" );
}
?>

```

If this is you complete PHP snippet I think you don't need the `die()`, it might be OK just to print out the failure image
You need use the quotes properly by either escaping the `"` or using a single `'`:

```
<?php
   $var=mysqli_query($db, $sql);

  if($var){
    echo"<img id='success' src='success.jpg'>
    <script>
    $('#success').fadeIn();
    $('#success').fadeOut(1000);
    </script>";
    }
    else
    {
    echo"<img id='failure' src='failure.jpg'>
    <script>
    $('#failure').fadeIn();
    $('#failure').fadeOut(1000);
    </script>";
    }
?>

```