Jragon Posted July 6, 2010 Share Posted July 6, 2010 My error: Parse error: syntax error, unexpected T_START_HEREDOC in C:\xampp\htdocs\movie\table2.php on line 22 My code: <?php //connect to mysql include("connect.php"); //make sure your using the right database mysql_select_db('moviesite') or die(mysql_error); //retrive 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) or die(mysql_error); //determine number of rows in returned result $num_movies = mysql_num_rows($result); $table <<<ENDHTML <div 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> <?php //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; ?> Please tell me what went wrong Link to comment https://forums.phpfreaks.com/topic/206925-getting-an-error-with-heredoc/ Share on other sites More sharing options...
Pikachu2000 Posted July 6, 2010 Share Posted July 6, 2010 You left out the assignment operator. $table = <<<ENDHTML Link to comment https://forums.phpfreaks.com/topic/206925-getting-an-error-with-heredoc/#findComment-1082094 Share on other sites More sharing options...
AbraCadaver Posted July 6, 2010 Share Posted July 6, 2010 You're also going to get one here: </tr> ENDHTML; Because there can't be any whitespace before the end of the heredoc block. Needs to be: </tr> ENDHTML; Also, that heredoc with the while loop in it is going to cause issues. You may have some things disorganized. Link to comment https://forums.phpfreaks.com/topic/206925-getting-an-error-with-heredoc/#findComment-1082106 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.