Jump to content

So why my heredoc statement is not accepted by php ?


cyber_alchemist

Recommended Posts

Having a parse error with my heredoc statement , so what is wrong with it ???



//retrieve information
$query = 'SELECT 
	movie_name, movie_year, movie_director, movie_leadactor, movie_type
	FROM 
		movie
	ORDER BY 
		movie_name ASC,
		movie_year DESC';
$result = mysql_query($query, $db) or die(mysql_error($db));

//determine the no. of rows in returned result
$num_movies = mysql_num_rows($result);

$table = <<<ENDHTML 

<div style="text-align: center" >
	<h2> Movie Review Database </h2>
	<table border="1" cellpadding="2" cellspacing="2" style="width: 70%; margin-left: auto; margin-right: auto;">
		<tr>
			<th>Movie Title</th>
			<th>Year of release</th>
			<th>Movie Director</th>
			<th>Movie Lead Actor</th>
			<th>Movie Type</th>
		</tr>
ENDHTML;

// loop through the result
while ($row = mysql_fetch_assoc($result)) {

	extract($row);
	
	$table .= <<<ENDHTML
	<tr>
		<td>$movie_name</td>
		<td>$movie_year</td>
		<td>$movie_director</td>
		<td>$movie_leadactor</td>
		<td>$movie_type</td>
	</tr>

ENDHTML;

}

$table .= <<<ENDHTML

</table>
</div>

<p align="center" >$num_movies Movies </p>

</div>

ENDHTML;

echo $table;

parse error : 'Parse error: syntax error, unexpected T_SL in table.php on line 22'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.