Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 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 December 31st, 2005, 10:36 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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
Reply With Quote
  #2 (permalink)  
Old January 1st, 2006, 03:59 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The parse error is due to the comma (,) in the line:
                   "Caddyshack",)

I hope this helps.

-- JB
Reply With Quote
  #3 (permalink)  
Old January 1st, 2006, 04:32 PM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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
Reply With Quote
  #4 (permalink)  
Old January 1st, 2006, 11:16 PM
Registered User
 
Join Date: Jan 2006
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I did not notice it earlier. A semicolon (;) is missing at the end of the line.
    "Caddyshack")
Reply With Quote
  #5 (permalink)  
Old January 2nd, 2006, 07:25 AM
Registered User
 
Join Date: Dec 2005
Location: , , .
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot jaybee. That has fixed the problem.
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
Chapter 1 - Getting Started - Adding Connection roscoe BOOK: Wrox's ASP.NET 2.0 Visual Web Developer 2005 Express Edition Starter ISBN: 978-0-7645-8807-5 6 November 6th, 2006 05:03 AM
Chapter 1 - Adding PHP to the Equation Chudz BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 3 June 27th, 2005 06:21 PM
Chapter 1 - Adding PHP to the Equation Chudz BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 7 June 22nd, 2005 11:32 AM



All times are GMT -4. The time now is 05:40 AM.


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