 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

May 16th, 2004, 12:52 PM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|
|

May 17th, 2004, 04:46 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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/
|
|

May 23rd, 2004, 05:53 AM
|
|
Registered User
|
|
Join Date: May 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks, problem is solved.
|
|

February 2nd, 2006, 12:05 PM
|
|
Registered User
|
|
Join Date: Feb 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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> </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> </td>';
}
print '</tr>';
}
print '</table>';
}
}
?>
</strong>
<body>
</body>
</html>
Kindly advice as to where is the error.
chandru
|
|
 |