 |
BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0  | This is the forum to discuss the Wrox book Beginning PHP5, Apache, and MySQL Web Development by Elizabeth Naramore, Jason Gerner, Yann Le Scouarnec, Jeremy Stolz, Michael K. Glass; ISBN: 9780764579660 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 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
|
|
|
|

December 31st, 2005, 10:36 AM
|
|
Registered User
|
|
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Chapter 2: Adding Arrays
I am on pg 70-72 of Beginning PHP5, Apache, MySQL Web Development and when I use the link from movie1.php to moviesite.php i get an error message
Parse error: parse error, unexpected T_IF in C:\Program Files\Apache Group\Apache2\htdocs\moviesite.php on line 29
This is my coding:
moviesite.php
<?php
session_start();
//check to see if user has logged on with a valid password
if ($_SESSION['authuser'] != 1) {
echo "Sorry you don't have permission to view this page, you loser!";
exit();
}
?>
<html>
<head>
<title>My Movie Site - <?php echo $_REQUEST['favmovie']; ?></title>
</head>
<body>
<?php include "header.php"; ?>
<?php
$favmovies = array("Life of Brian",
"Stripes",
"Office Space",
"The Holy Grail",
"Matrix",
"Terminator",
"Star Wars",
"Close Encounters of the Third Kind",
"Sixteen Candles",
"Caddyshack",)
if (isset($_REQUEST['favmovie'])) {
echo "Welcome to our site, ";
echo $_SESSION['username'];
echo "! <br>";
echo "My favourite movie is ";
echo $_REQUEST['favmovie'];
echo "<br>";
$movierate = 5;
echo "My movie rating for this movie is: ";
echo $movierate;
} else {
echo "My top 10 movies are:<br>";
if (isset($_REQUEST['sorted'])) {
sort($favmovies);
}
foreach ($favmovies as $currentvalue) {
echo $currentvalue;
echo "<br>\n";
}
}
?>
</body>
</html>
movie1.php
<?php
session_start();
$_SESSION['username'] = $_POST['user'];
$_SESSION['userpass'] = $_POST['pass'];
$_SESSION['authuser'] = 0;
//check username and password information
if(($_SESSION['username'] == 'Joe') and
($_SESSION['userpass'] == '12345')) {
$_SESSION['authuser'] = 1;
} else {
echo "Sorry, but you don't have permission to view this page, you loser!";
exit();
}
?>
<html>
<head>
<title>Find My Favorite Movie</title>
</head>
<body>
<?php include "header.php"; ?>
<?php
$myfavmovie = urlencode("The Life of Brian");
echo "<a href='moviesite.php?favmovie=$myfavmovie'>";
echo "Click here to see more information about my favorite movie!";
echo "</a>";
echo "<br>";
echo "<a href='moviesite.php'>";
echo "Click here to see my top 10 movies.";
echo "</a>";
echo "<br>";
echo "<a href='moviesite.php?sorted=true'>";
echo "Click here to see my top 10 movies, sorted alphabetically.";
echo "</a>";
?>
</body>
</html>
thanks in advance
|
|

January 1st, 2006, 03:59 PM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The parse error is due to the comma (,) in the line:
"Caddyshack",)
I hope this helps.
-- JB
|
|

January 1st, 2006, 04:32 PM
|
|
Registered User
|
|
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I have removed the comma in th "Caddyshack",) line but still have a parse error.
Thanks for the post but it doesn't seem to have fixed the problem
|
|

January 1st, 2006, 11:16 PM
|
|
Registered User
|
|
Join Date: Jan 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I did not notice it earlier. A semicolon (;) is missing at the end of the line.
"Caddyshack")
|
|

January 2nd, 2006, 07:25 AM
|
|
Registered User
|
|
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks alot jaybee. That has fixed the problem.
|
|
 |