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
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.