PDA

View Full Version : what does this error mean?



jr_yeo
04-15-2007, 12:31 PM
Parse error: syntax error, unexpected $end in C:\wamp\www\jryeo\movie.php on line 162

<?php
require_once("config.php");
require_once("opendb.php");
$peoplesql = "SELECT
*
FROM
`people`
";
$result = mysql_query($peoplesql)
or die("Invalid query: " . mysql_error());
while( $row = mysql_fetch_array( $result , MYSQL_ASSOC )){
$people[ $row['people_id'] ] = $row['people_fullname'];
}

switch( $_GET['action'] ){
case "edit":
$moviesql = "SELECT
*
FROM
`movie`
WHERE
`movie`.`movie_id` = '".$_GET['id']."'
";
$result = mysql_query($moviesql)
or die("Invalid query: " . mysql_error());
$row = mysql_fetch_array( $result , MYSQL_ASSOC );
$movie_name = $row[ 'movie_name' ];
$movie_type = $row[ 'movie_type' ];
$movie_year = $row[ 'movie_year' ];
$movie_leadactor = $row[ 'movie_leadactor' ];
$movie_director = $row[ 'movie_director' ];
break;
default:
$movie_name = "";
$movie_type = "";
$movie_year = "";
$movie_leadactor = "";
$movie_director = "";
break;
}
?>
<html>
<head>
<TITLE><?php echo $_GET['action']?> movie</TITLE>
</head>
<body>
<FORM action="commit.php?action=<?php echo $_GET['action']?>&type=movie&id=<?php echo $_GET['id']?>" method="post">
<table border=0 width="750" cellspacing=1 cellpadding=3 bgcolor="#353535" align="center">
<tr>
<td bgcolor="#ffffff" width="30%">
Movie Name
</td>
<td bgcolor="#ffffff" width="70%">
<input type="text" name="movie_name" value="<?php echo $movie_name?>">
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
Movie Type
</td>
<td bgcolor="#ffffff">
<SELECT id="game" name="movie_type" style="width:150px">
<?php
$sql = "SELECT
`movietype_id`,
`movietype_label`
FROM
`movietype`
ORDER BY
`movietype_label`
";
$result = mysql_query($sql)
or die("<font color=\"#FF0000\">Query Error</FONT>".mysql_error());
while ( $row = mysql_fetch_array($result) ){
if ( $row['movietype_id'] == $movie_type){
$selected = " SELECTED";
} else {
$selected = "";
}
echo '<OPTION value="'.$row['movietype_id'].'"'.$selected.'>'.$row['movietype_label'].'</OPTION>'."\r\n";
}
?>
</SELECT>

</td>
</tr>
<tr>
<td bgcolor="#ffffff">
Movie Year
</td>
<td bgcolor="#ffffff">
<SELECT name="movie_year">
<option value="" SELECTED>Select a year...</option>
<?php
for ($year=date("Y"); $year >= 1970 ;$year--){
if ( $year == $movie_year){
$selected = " SELECTED";
} else {
$selected = "";
}
?>
<option value="<?php echo $year?>"<?php echo $selected?>><?php echo $year?></option>
<?
}
?>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
Lead Actor
</td>
<td bgcolor="#ffffff">
<SELECT name="movie_leadactor">
<option value="" SELECTED>Select an actor...</option>
<?php
foreach( $people as $people_id => $people_fullname ){
if ( $people_id == $movie_leadactor){
$selected = " SELECTED";
} else {
$selected = "";
}
?>
<option value="<?php echo $people_id?>"<?php echo $selected?>><?php echo $people_fullname?></option>
<?php
}
?>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#ffffff">
Director
</td>
<td bgcolor="#ffffff">
<SELECT name="movie_director">
<option value="" SELECTED>Select a director...</option>
<?php
foreach( $people as $people_id => $people_fullname ){
if ( $people_id == $movie_director){
$selected = " SELECTED";
} else {
$selected = "";
}
?>
<option value="<?php echo $people_id?>"<?php echo $selected?>><?php echo $people_fullname?></option>
<?php
}
?>
</SELECT>
</td>
</tr>
<tr>
<td bgcolor="#ffffff" colspan=2 align="center">
<INPUT type="SUBMIT" name="SUBMIT" value="<?php echo $_GET['action']?>">
</td>
</tr>
</table>
</FORM>
</body>
</html>


tnx.

Twey
04-15-2007, 01:00 PM
Means the file ended unexpectedly... usually, you've left something open -- braces, brackets, quotes?

jr_yeo
04-15-2007, 01:13 PM
but if i turn on the "short open tag" feature
the error message goes *poof*... :)

Twey
04-15-2007, 01:17 PM
<?
}
?> Without short tags, this isn't parsed as PHP, and the block is left open.

JShor
04-16-2007, 05:57 AM
This happens often to me with long lines of variables. Usually, I leave something un-ended like ) , ] , } . It also can be solved with this code:

<?php } ?>