imstylin1 Posted November 29, 2012 Share Posted November 29, 2012 I have the following code: <?php $link=mysql_connect("localhost","root","") or die (mysql_error()); mysql_select_db("moviesite") or die(mysql_error()); $query="SELECT movie_name, movie_director, movie_leadactor FROM movie"; $result=mysql_query($query, $link) or die (mysql_error()); $num_movies=mysql_num_rows($result); $movie_header=<<<EOD <h2><center>Movie Review Database</center></h2> <table width="70%" border="1" cellpadding="2" cellspacing="2" align="center"> <tr> <th>Movie Title</th> <th>Movie Director</th> <th>Movie Lead Actor</th> </tr> EOD; $movie_details=''; while ($row = mysql_fetch_array($result)) { $movie_name = {$row['movie_name']}; $movie_director = {$row['movie_director']}; $movie_leadactor={$row['movie_leadactor']}; $movie_details .=<<<EOD <tr> <td>$movie_name</td> <td>$movie_director</td> <td>$movie_leadactor</td> </tr> EOD; } $movie_details .=<<<EOD <tr> <td> </td> </tr> <tr> <td>Total :$num_movies Movies</td> </tr> EOD; $movie_footer="</table>"; $movie = <<<MOVIE $movie_header $movie_details $movie_footer MOVIE; echo "There are $num_movies movies in our database"; echo $movie; ?> DW shows syntax error on line 60 : which is "echo $movie:" when I remark the line, syntax doesn't go away so I know its not related to this line. When I delete the line, the error goes to the previous line. When I run in browser, I get: Parse error: syntax error, unexpected end of file in C:\wamp\www\test2\table2.php on line 60 I suspect that I missed something. Please help! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/ Share on other sites More sharing options...
Barand Posted November 29, 2012 Share Posted November 29, 2012 Unexpected end of file is a symptom of mismatched {..}s. Probably one missing somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396175 Share on other sites More sharing options...
imstylin1 Posted November 29, 2012 Author Share Posted November 29, 2012 I'll look... thanks. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396177 Share on other sites More sharing options...
imstylin1 Posted November 29, 2012 Author Share Posted November 29, 2012 All the {} and () seem to be there. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396178 Share on other sites More sharing options...
imstylin1 Posted November 29, 2012 Author Share Posted November 29, 2012 DW didn't like $movie_name = {$row['movie_name']}; without the {} around $row['movie_name']; but the book i am learning from doesn't show them. This leads me to believe the book is missing something that is now needed for proper syntax. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396179 Share on other sites More sharing options...
PFMaBiSmAd Posted November 29, 2012 Share Posted November 29, 2012 I get a different error, so I suspect that the forum software removed some white-space you had before/after the closing heredoc tags. The closing EOD; and MOVIE; tags must start in column one of the line they are in and they also cannot have anything after the ; Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396180 Share on other sites More sharing options...
imstylin1 Posted November 29, 2012 Author Share Posted November 29, 2012 Could hitting the spacebar after one of the heredoc tags be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396181 Share on other sites More sharing options...
imstylin1 Posted November 29, 2012 Author Share Posted November 29, 2012 PFMaBiSmAd solved the issue for me. Dreamweaver was putting spaces in ending heredoc tags. Put them in column 1 and it fixed the issue. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396183 Share on other sites More sharing options...
Christian F. Posted December 1, 2012 Share Posted December 1, 2012 DW didn't like $movie_name = {$row['movie_name']}; without the {} around $row['movie_name']; but the book i am learning from doesn't show them. This leads me to believe the book is missing something that is now needed for proper syntax. PFMaBiSmAd solved the issue for me. Dreamweaver was putting spaces in ending heredoc tags. Put them in column 1 and it fixed the issue. The book is entirely correct, you don't need (nor do you want) to use square brackets around that variable. That is, if it is indeed written as it appears in your post. Combined with the second quote, and what I've seen done by DW here, I think it's safe to say that the proper solution is not to use DW. There are lots of other editors out there, and many of them are listed in the Editors thread. You should be able to find something you like there, something which actually works properly. Quote Link to comment https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/#findComment-1396620 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.