HEREDOC Retornando final inesperado
O fragmento a seguir está causando um
"Erro de análise do PHP: erro de sintaxe, $ end inesperado em / Applications / MAMP / htdocs3 / nettuts / PHP / PDO para acesso ao banco de dados / htdocs / view_users02.php na linha 39"
Procurei no site e no google, mas não encontrei uma solução exat
foreach($DBH->query($sql) as $row){
$output = "<tr><td align='left'>" . $row["name"] . "</td><td align='left'>" . $row["dr"] . "</td></tr>";
// echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>';
echo <<<EOT
$output
EOT;
Script Completo
<?php
$page_title = 'View the Current Users';
include ('includes/header.html');
// Page header:
echo '<h1>Registered Users</h1>';
require_once ('../mysql_pdo_connect.php'); // Connect to the db.
// Make the query:
$sql = "SELECT CONCAT(last_name, ', ', first_name) AS name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_date ASC";
// Table header.
echo <<<EOT
<table align='center' cellspacing='3' cellpadding='3' width='75%'>
<tr><td align='left'><b>Name</b></td><td align='left'><b>Date Registered</b></td></tr>
EOT;
foreach($DBH->query($sql) as $row){
$output = "<tr><td align='left'>" . $row["name"] . "</td><td align='left'>" . $row["dr"] . "</td></tr>";
// echo '<tr><td align="left">' . $row['name'] . '</td><td align="left">' . $row['dr'] . '</td></tr>';
echo <<<EOT
$output
EOT;
}
echo '</table>'; // Close the table.
$DBH = null;
include ('includes/footer.html');
?>