Else does not work in PHP

2

I'm trying to use the code below, but else does not work. Returns the error Parse error: syntax error, unexpected 'else' (T_ELSE)

<?php if ($status == 'True') ?>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
    <img src="'.$poster.'" class="poster">
</div>
<div class="col-lg-9 col-md-9 col-sm-9 col-xs-9">
    <div class="imdb-panel">
        <div class="imdb-head">
            <?php echo $title; ?>
        </div>
        <div class="imdb-body">
            <p style="margin: 0">Nome: <?php echo $title ?></p>
            <br>
            <p style="margin: 0">Data de lançamento: <?php echo $released ?></p>
            <br>
            <p style="margin: 0">Dirigido por: <?php echo $director ?></p>
            <br>
            <p style="margin: 0">Escrito por: <? echo $writer ?></p>
            <br>
            <p style="margin: 0">Elenco principal: <?php echo $actors ?></p>
        </div>
    </div>
</div>
<?php else: ?>
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
    <div class="imdb-panel">
        <div class="imdb-head">
            Título não encontrado
        </div>
        <div class="imdb-body">
            <p style="text-align: center;">O título que você procurou não pode ser encontrado.</p>
        </div>
    </div>
</div>
<?php endif ?>
    
asked by anonymous 19.02.2017 / 01:12

1 answer

4

The : was missing on the first line:

<?php if ($status == 'True'): ?>
----------------------------^

And ; at the end:

<?php endif; ?>
-----------^

In the third line, there is something that does not make sense:

<img src="'.$poster.'" class="poster">
-----------^^^^^^^^^

Would you be concatenating a PHP variable within HTML? Replace with echo :

<img src="<?php echo $poster; ?>" class="poster">
    
19.02.2017 / 01:15