Jump to content

Need Help Finding Syntax Error


imstylin1

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/271345-need-help-finding-syntax-error/
Share on other sites

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 ;

  On 11/29/2012 at 2:49 PM, imstylin1 said:

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.

  On 11/29/2012 at 2:58 PM, imstylin1 said:

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.

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.