Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6
This is the forum to discuss the Wrox book Beginning PHP, Apache, MySQLWeb Development by Michael K. Glass, Yann Le Scouarnec, Elizabeth Naramore, Gary Mailer, Jeremy Stolz, Jason Gerner; ISBN: 9780764557446
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 16th, 2004, 12:52 PM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default parse error $end pag 118 table3.php

Hello,

I'm having a problem with the assignment on page 118, table3.php. I keep getting this error.

Parse error: parse error, unexpected $end in C:\Program Files\Apache Group\Apache2\htdocs\beginningPHP\table1.php on line 86

Could somebody help me so i can gett on with this fantastic book

This is my code:

<?php
$link=mysql_connect("localhost", "*******", "******") or die ("De verbinding met de database is mislukt");

$query="SELECT movie_id, 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;

function get_director() {
    global $movie_director;
    global $director;

    $query_d = "SELECT people_fullname
            FROM people
            WHERE people_id='$movie_director' ";
    $results_d = mysql_query($query_d) or die(mysql_error());
    $row_d = mysql_fetch_array($results_d);
    extract ($row_d);
    $director = $people_fullname;
}

function get_leadactor() {
    global $movie_leadactor;
    global $leadactor;

    $query_a = "SELECT people_fullname
            FROM people
            WHERE people_id='$movie_leadactor'";
    $results_a = mysql_query($query_a) or die(mysql_error());
    $row_a = mysql_fetch_array($results_a);
    extract ($row_a);
    $leadactor = $people_fullname;
}

while($row = mysql_fetch_array($result))
{
    $movie_id = $row['movie_id'];
    $movie_name = $row['movie_name'];
    $movie_director = $row['movie_director'];
    $movie_leadactor = $row['movie_leadactor'];

get_director($movie_director);

get_leadactor($movie_leadactor);

$movie_details .=<<<EOD
  <tr>
    <td><a href='movie_details.php?movie_id=$movie_id'title=' Find out more about $movie_name'>$movie_name</td>
    <td>$director</td>
    <td>$leadactor</td>
  </tr>
EOD;
  }


$movie_details .=<<<EOD
  <tr>
    <td>Totaal:$num_movies Movies</td>
  </tr>
EOD;

$movie_footer ="</table>";

$movie =<<<MOVIE
    $movie_header
    $movie_details
    $movie_footer
MOVIE;

    print "There are $num_movies movies in our database";
    print $movie;
?>

posted by Vincent Kranendonk.



Reply With Quote
  #2 (permalink)  
Old May 17th, 2004, 04:46 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can't have __ANY__ characters on the line that terminates a heredoc string except for your closing identifier and a semicolon. If you have any other characters, including whitespace, PHP will assume that the line is just part of your string and keep looking for the end token.

If you look at the string starting with $movie +=<<<EOD, the terminating line has whitespace after the terminating identifier. Delete that whitespace and it should work fine.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old May 23rd, 2004, 05:53 AM
Registered User
 
Join Date: May 2004
Location: , , .
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, problem is solved.

Reply With Quote
  #4 (permalink)  
Old February 2nd, 2006, 12:05 PM
Registered User
 
Join Date: Feb 2006
Location: Chennai, TamilNadu, India.
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to changusee2k
Default

Hi all,

I'm also getting this error ......
Parse error: parse error, unexpected $end in D:\Program Files\Apache Group\WEBS\Test\calendar.php on line 162

The PHP code is given below.
Code:
<html>
<head>
<title> Displaying a Calendar </title>
</head>
<strong>
<?php
//Use Form Helpfer Functions.
require 'formhelpers.php';

$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April',
        5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
        9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');

$years = array();
for ($year = daye('Y') - 1, $max_year = date('Y') + 5; $year < $max_year; $year++)
{
    $years[$year] = $year;
}

if ($_POST['_submit_check'])
{
    if ($errors = validate_form())
    {
        show_form($errors);
    }
    else
    {
        show_form();
        process_form();
    }
}
else
{
// When nothing is submitted, show the form and then a calendar for the current month
    show_form();
    show_calender(date('n'),date('Y'));
}

function validate_form()
{
    global $months, $years;
    $errors = array();

    if (! array_key_exists($_POST['month'], $months))
    {
        $errors[] = 'Select a Valid Month.';
    }

    if (! array_key_exists($_POST['year'], $years))
    {
        $errors[] = 'Select a Valid Year.';
    }

    return $errors;
}

function show_form($errors = '')
{
    global $months, $years, $this_year;

    // If the Form is submitted get the default form submitted variables.
    if ($_POST['_submit_check'])
    {
        $defaults = $_POST;
    }
    else
    {
    // Otherwise, Set your own defaults : Current month and year.
        $defaults = array('year' => date('Y'),
                          'month' => date('n'));
    }

    if ($errors)
    {
        print 'You need to correct the following errors :[list]<li>';
        print implode('</li><li>', $errors);
        print '</li></ul>';
    }

    print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
    input_select('month', $defaults, $months);
    input_select('year', $defaults, $years);
    input_submit('submit', 'Show Calendar');
    print '<input type="hidden" name="_submit_check" value="1"/>';
    print '</form>';
}

function process_form()
{
    show_calendar($_POST['month'], $_POST['year']);
}

function show_calendar($month, $year)
{
    global $months;
    $weekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');

    //Find the timestamp for midnight on the first day of the month.
    $first_day = mktime(0,0,0,$month, 1,$year);

    //The number of days in month.
    $days_in_month = date('t',$first_day);

    //Determine which day of the week as the first day of the month?
    //Make sure the first table cell is put in its right place.
    $day_offset = date('w', $first_day);

    //print the table header and row of weekday names
    print<<<_HTML_
    <table border="0" cellspacing="0" cellpadding="2">
    <tr><th colspan="7">$months[$month] $year</th></tr>
    <tr><td align="center">
    _HTML_;
    print implode('</td><td align="center">', $weekdays);
    print '</td></tr>';

    // Align the first day of the month under the correct day table cells.
    if ($day_offset > 0)
    {
        for ($i = 0; $i < $day_offset; $i++)
        {
            print '<td>&nbsp;</td>';
        }

        // print a table cell for each day of the month.
        for ($day = 1; $day <= $days_in_month; $day++)
        {
            print '<td align = "center">' . $day . '</td>';
            $day_offset++;

            // If cell is the seventh, then end of table row and reset $day_offset
            if ($day_offset == 7)
            {
                $day_offset = 0;
                print "</tr>\n";

                // start new table row for the rest of the month till the end of month.
                if ($day < $days_in_month)
                {
                    print '<tr>';
                }
            }
        }

        // Checking for last day of the month and if it is not a saturday
        // then pad them with blank cells till end of row.
        if ($day_offset > 0)
        {
            for ($i = $day_offset; $i < 7 ; $i++)
            {
                print '<td>&nbsp;</td>';
            }
            print '</tr>';
        }
        print '</table>';
    }
}
?>
</strong>
<body>
</body>
</html>
Kindly advice as to where is the error.

chandru
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP Parse error: parse error, unexpected T_STRING geminient PHP How-To 4 August 18th, 2007 02:27 AM
Parse error: parse error, unexpected $end Ayodeji Adegbaju Pro PHP 3 January 12th, 2007 12:21 PM
Chapter 4 table3.php mojo11ku BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 February 16th, 2006 07:39 PM
php parse error ajit_kunte BOOK: Professional PHP 5 ISBN: 978-0-7645-7282-1 2 May 2nd, 2005 07:24 AM



All times are GMT -4. The time now is 11:55 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.