Page 1 of 1

parse error help

Posted: Sun Apr 12, 2009 10:45 pm
by ultrajet
Hi everyone,

I'm a php newbie and am using a xampp and a book to learn php. Unfortunately while following the codes in the book, I kept getting parse error. I don't know why. Please check if you can see what's wrong with it. Thanks

This is the code for movierate.php

Code: Select all

 
<?php
session_start();
//check to see if user has logged in with a valid password
if ($_SESSION[‘authuser’] != 1) {
echo “Sorry, but 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
echo “Welcome to our site, “;
echo $_SESSION[‘username’];
echo “! <br>”;
echo “My favorite movie is “;
echo $_REQUEST[‘favmovie’];
echo “<br>”;
$movierate = 5;
echo “My movie rating for this movie is: “;
echo $movierate;
?>
</body>
</html>
 
This is the code for movierate1.php

Code: Select all

 
<?php
session_start();
if ($_SESSION[‘authuser’] != 1) {
echo “Sorry, but 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
echo “Welcome to our site, “;
echo $_SESSION[‘username’];
echo “! <br>”;
echo “My favorite movie is “;
echo $_REQUEST[‘favmovie’];
echo “<br>”;
$movierate = 5;
echo “My movie rating for this movie is: “;
echo $movierate;
?>
</body>
</html>
 

Re: parse error help

Posted: Sun Apr 12, 2009 10:52 pm
by requinix
ultrajet wrote:Unfortunately while following the codes in the book, I kept getting parse error. I don't know why.
But you do know something we don't: which file has the error and on which line. It's clearly stated in the error message.

Re: parse error help

Posted: Sun Apr 12, 2009 10:55 pm
by ultrajet
while in browser it writes:
Parse error: parse error in C:\xampp\htdocs\PHP\moviesite.php on line 3

Any ideas how to fix this?

Re: parse error help

Posted: Sun Apr 12, 2009 11:20 pm
by requinix
Well, little problem here. You posted movierate.php and movierate1.php, yet the error specifically mentions moviesite.php.

How about posting that one?

Re: parse error help

Posted: Tue Apr 14, 2009 2:44 pm
by McInfo
Are you using MS Word or some other rich text editor to write your script?

Notice the single and double quotes.

Code: Select all

if ($_SESSION[‘authuser’] != 1)
    echo “Sorry, but you don’t have permission to view this page!”;
is not the same as

Code: Select all

if ($_SESSION['authuser'] != 1)
    echo "Sorry, but you don’t have permission to view this page!";
Write code with a text editor that uses ASCII characters, not a word processor that turns your keystrokes into weird characters.

I recommend Eclipse PDT.

Edit: This post was recovered from search engine cache.