mercredi 26 février 2020

PHP error: HeredocStart expected, syntax error unexpected end of file

I'm developing a PHP script for my online store and I'm getting this error when I try to use Heredocs. Can you guys help me? When I delete the $prodotti variable, everything works fine.

<?php
function show_products(){
    global $connection;

    $query = "SELECT * FROM prodotto";
    $result = mysqli_query($connection, $query) or die(mysqli_error($connection));

    if($num_rows = mysqli_num_rows($result)){
        while($row = mysqli_fetch_assoc($result)){
          $prodotti = <<<STRINGA_PDT

          <div class="col-lg-4 col-md-6 mb-4">
          <div class="card h-100">
          <img class="card-img-top" src="../risorse/IMAGES/{$row['immagine']}" alt="">
            <div class="card-body">
              <h4 class="card-title">
                <a href="prodotto.php?id={$row['id_prodotto']}">{$row['nome_prodotto']}</a>
              </h4>
              <h5>€{$row['prezzo']}</h5>
              <p class="card-text">{$row['descr_prodotto']}</p>
            </div>
            <div class="card-footer text-center">
            <a href="carrello.php?add={$row['id_prodotto']}"><button type="button" class="btn btn-primary btn-small">Acquista</button></a>
            <a href="prodotto.php?id={$row['id_prodotto']}" class="btn btn-success btn-small">Dettagli</a>
            </div>
          </div>
        </div>

          STRINGA_PDT;
        }
    }
}

?>




Aucun commentaire:

Enregistrer un commentaire