我在第18行發生了錯誤。您可以看到在<<<ENDHTML
之後沒有空間,但我無法擺脫錯誤。我甚至認爲我需要把<?php?>
覆蓋整個代碼。它也沒有使它工作。我是這樣做的,但我無法擺脫錯誤
<?php
$db= mysql_connect('localhost','root','') or die('Unable to connect. Check your connect parameters');
$query = 'CREATE DATABASE IF NOT EXISTS moviesite';
mysql_query($query,$db) or die(mysql_error($db));
mysql_select_db('moviesite', $db) or die(mysql_error($db));
$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));
$num_movies = mysql_num_rows($result);
//needs to show the same result as table1
$table = <<<ENDHTML<div style="text-align: center;">
<h2>Movie Review Database</h2>
<table border="0" cellspacing="2" cellpadding="2" style="width:60%; margin: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;
while($row = mysql_fetch_array($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>
<p>$num_movies Movies</p>
ENDHTML;
</div>
?>
<p><?php echo $num_movies?>Movies</p>
我不確定您是否看過我的原始帖子/回覆,但我已經做了一些修改,您可能沒有看到所做的更改/添加。如果是這樣,請重新加載它以查看更改。 –