I am attempting to build a PDF based on the information in a database that I have. I am getting a 500 internal server error when I do. The code that is throwing the error is:
<?php
include('db.php');
$pdfArray = array();
$top = '<h1>Med One Equipment List</h1>
<table>
<thead>
<tr>
<td>Manufacturer</td>
<td>Model</td>
<td>Description</td>
</tr>
</thead>
<tbody>
';
array_push($pdfArray, $top);
while($rowAll = mssql_fetch_array($allResult)) {
$html = '
<tr>
<td>'.$rowAll["Manufacturer"].'</td>
<td>'.$rowAll["Model"].'</td>
<td>'.$rowAll["Make"].'</td>
<tr>';
array_push($pdfArray, $html);
}
$bottom = '</tbody>
</table>';
array_push($pdfArray, $bottom);
$table = implode(" ", $pdfArray);
$html = <<<EOF
{$table}
EOF;
?>
I am just including this file when I build my PDF with TCPDF. Let me know if I need to include some of the TCPDF code. I can't for the life of my figure out why it won't work. My guess is that I'm using herdoc incorrectly.
From looking at the raw formatting of your code, it looks like
$html = <<<EOF
{$table}
EOF;
is indented with a tab. If that is the case in your real code, the problem is that the end of a heredoc must be the first thing on a line. If it is indented at all, it will break. So if your code is indented, it will need to look something like this:
if($example_block){
$html = <<<EOF
{$table}
EOF;
{other indented code}
}
P.S. The observations about the indenting with a tab I mentioned above were from before the question was edited, but wither way, if it is indented with a tab or spaces, it will break. Also, Kyle is is correct in stating that the opening identifier must also be immediately followed by a new line.
I just copy and pasted your code. The error is coming from a space that is located just after your <<<EOF
line.
You have $html = <<<EOF(space)
.
Should be $html = <<<EOF
.