www.webdeveloper.com
Results 1 to 6 of 6

Thread: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

  1. #1
    Join Date
    May 2012
    Posts
    4

    syntax error, unexpected T_ENCAPSED_AND_WHITESPACE

    please help to how to fix

    <?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;
    ?>

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,321
    We can't tell what sort of indentation you used since you used [quote] tags around your code instead of [php] 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.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    May 2012
    Posts
    42
    It would also help if you told us the line number that the error is returning.
    Keith

    Freelance PHP Web Developer
    http://www.duvalltech.com/

  4. #4
    Join Date
    May 2012
    Posts
    4
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Movie Review Website\movie_details.php on line 153

    please help how to fix error

  5. #5
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,321
    Quote Originally Posted by thumati View Post
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\wamp\www\Movie Review Website\movie_details.php on line 153

    please help how to fix error
    You probably have white-space of some sort at the beginning of line 146 (one of the ENDHTML; lines).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  6. #6
    Join Date
    May 2012
    Posts
    4
    thanks for the support

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles