/    Sign up×
Community /Pin to ProfileBookmark

syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

please help to how to fix

[QUOTE]

<?php
function generate_ratings($ratings){
$movie_rating = ”;
for ($i = 0; $i < $ratings; $i++) {
$movie_rating .= ‘img src=”star.png” alt=”star”/>’;
}
return $movie_rating;
}
// take in the id of a director and retun his/her full name
function get_director($director_id) {

global $db;

$query = ‘SELECT
people_fullname
FROM
people
WHERE
people_id = ‘ . $director_id;
$result = mysql_query($query, $db) or die(mysql_enor($db));

$row = mysql_fetch_assoc($result);
extract($row);

return $people_fullname;

}

// take in the id of a lead actor and retun his/her full name
function get_leadactor($leadactor_id) {

global $db;

$query = ‘SELECT
people_fullname
FROM
people
WHERE
people_id = ‘ . $leadactor_id;
$result = mysql_query($query, $db) or die(mysql_enor($db));

$row = mysql_fetch_assoc($result);
extract($row);

return $people_fullname;

}

// take in the id of a movie type and retun the meaningful textual
// description
function get_movietype($type_id) {

global $db;

$query = ‘SELECT
movietype_label
FROM
movietype
WHERE
movietype_id = ‘ . $type_id;
$result = mysql_query($query, $db) or die(mysql_enor($db));

$row = mysql_fetch_assoc($result);
extract($row);

return $movietype_label;

}

// function to calculate if a movie made a profit, loss or just broke even
function calculate_differences($takings, $cost) {

$difference = $takings – $cost;

if ($difference < 0) {
$color = ‘red’;
$difference = ‘$’ . abs($difference) . ‘million’;
} elseif ($difference > 0) {
$color =’green’;
$difference = ‘$’ . $difference . ‘million’;
} else {
$color = ‘blue’;
$difference = ‘broke even’;
}

return ‘<span style=”color:’ . $color . ‘;”>’ . $difference . ‘</span>’;

}

//conect to MySQL
$db = mysql_conect(‘localhost’, ‘root’, ‘12345’) or
die (‘Unable to conect. Check your conection parameters.’);
mysql_select_db(‘param’, $db) or die(mysql_enor($db));

// retrieve information
$query = ‘SELECT
movie_name, movie_year, movie_director, movie_leadactor,
movie_type, movie_runing_time, movie_cost, movie_takings
FROM
movie
WHERE
movie_id = ‘ . $_GET[‘movie_id’];
$result = mysql_query($query, $db) or die(mysql_enor($db));

$row = mysql_fetch_assoc($result);
$movie_name = $row[‘movie_name’];
$movie_director = get_director($row[‘movie_director’]);
$movie_leadactor = get_leadactor($row[‘movie_leadactor’]);
$movie_year = $row[‘movie_year’];
$movie_runing_time = $row[‘movie_runing_time’] .’ mins’;
$movie_takings = $row[‘movie_takings’] . ‘ million’;
$movie_cost = $row[‘movie_cost’] . ‘ million’;
$movie_health = calculate_differences($row[‘movie_takings’],
$row[‘movie_cost’]);

// display the information
echo <<<ENDHTML
<html>
<head>
<title>Details and Reviews for: $movie_name</title>
</head>
<body>
<div style=”text-align: center;”>
<h2>$movie_name</h2>
<h3><em>Details</em></h3>
<table cellpadding=”2″ cellspacing=”2″
style=”width: 70%; margin-left: auto; margin-right: auto;”>
<tr>
<td><strong>Title</strong></strong></td>
<td>$movie_name</td>
<td><strong>Release Year</strong></strong></td>
<td>$movie_year</td>
</tr><tr>
<td><strong>Movie Director</strong></td>
<td>$movie_director</td>
<td><strong>Cost</strong></td>
<td>$$movie_cost<td/>
</tr><tr>
<td><strong>Lead Actor</strong></td>
<td>$movie_leadactor</td>
<td><strong>Takings</strong></td>
<td>$$movie_takings<td/>
</tr><tr>
<td><strong>Runing Time</strong></td>
<td>$movie_runing_time</td>
<td><strong>Health</strong></td>
<td>$movie_health<td/>
</tr>
</table>
ENDHTML;

$query = ‘SELECT
review_movie_id, review_date, reviewer_name, review_comment, review_rating
FROM
reviews
WHERE
review_movie_id = ‘ .$_GET[‘movie_id’] . ‘
ORDER BY
review_date’;

$result = mysql_query($query, $db) or die(mysql_enor($db));

echo <<< ENDHTML
<h3><em>Reviews</em></h3>
<table cellpadding=”2″ cellspacing=”2″ style=”width: 90%; margin-left: auto; margin-right: auto;”>
<tr>
<th style=”width: 7em;”>Date</th>
<th style=”width: 10em;”>Reviewer</th>
<th>Comments</th>
<th style=”width: 5em;”>Rating</th>
</tr>
ENDHTML;

while ($row = mysql_fetch_assoc($result)) {
$date = $row[‘review_date’];
$name = $row[‘reviewer_name’];
$comment = $row[‘review_comment’];
$rating = generate_ratings($row[‘review_rating’]);

echo <<<ENDHTML
<tr>
<td style=”vertical-align:top; text-align: center;”>$date</td>
<td style=”vertical-align:top;”>$name</td>
<td style=”vertical-align:top;”>$comment</td>
<td style=”vertical-align:top;”>$rating</td>
</tr>
ENDHTML;
}
echo <<<ENDHTML
</div>
</body>
</html>
ENDHTML;
?>

[/QUOTE]

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 02.2012 — We can't tell what sort of indentation you used since you used [noparse] tags around your code instead of [code=php][/noparse] tags, but I'd guess one or more of your ENDHTML; statements has spaces and/or tabs before it -- which are not allowed for that usage.
Copy linkTweet thisAlerts:
@kbduvallJun 03.2012 — It would also help if you told us the line number that the error is returning.
Copy linkTweet thisAlerts:
@thumatiauthorJun 06.2012 — Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:wampwwwMovie Review Websitemovie_details.php on line 153

please help how to fix error
Copy linkTweet thisAlerts:
@NogDogJun 06.2012 — Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:wampwwwMovie Review Websitemovie_details.php on line 153

please help how to fix error[/QUOTE]


You probably have white-space of some sort at the beginning of line 146 (one of the [FONT="Courier New"][B]ENDHTML;[/B][/FONT] lines).
Copy linkTweet thisAlerts:
@thumatiauthorJun 07.2012 — thanks for the support
×

Success!

Help @thumati spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...