BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143
This is the forum to discuss the Wrox book Beginning PHP 6, Apache, MySQL 6 Web Development by Timothy Boronczyk, Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz; ISBN: 9780470391143
You are currently viewing the BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
I have checked this code from pages 111/112 and cannot find a typo BUT I get " Parse error: syntax error, unexpected $end in C:\wamp\www\movies\table2.php on line 61" The problem is there are only 60 lines in the code.
What am I missing?
Code:
<?php
//connect to MySQL
$db=mysql_connect('localhost', 'bp6am','bp6ampass') or die
('Unable to connect.Check your connection parameters');
//make sure you are using the right database.
mysql_select_db('moviesite',$db) or die (mysql_error($db));
//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 number of rows
$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 results
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>
<p> $num_movies Movies </p>
</div>
ENDHTML;
?>
echo $table;
Actually I read past page 113. Before submitting my problem I checked and double-checked all of the heredoc syntax - removed all spaces that I found.
I am using Geany as a writer - does this program add spaces?4 My code has, say 59 numbered lines when I save the document but when I reopen it it has 60 lines, the last one being blank.