on execution of my program it is giving following error Parse error: parse error, unexpected T_STRING, expecting ',' or ';' in E:\xampplite\htdocs\practice\test\moviesite.php on line 7 my program code is this <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?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 fav site is <?php echo $_REQUEST['favmovie'] ?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php echo "my fav movie is "; echo $_REQUEST['favmovie'] ; $movierate=5; echo "my movierate for this movie is "; echo $movierate; ?> </body> </html> Please help me to solve this error. Thanks.
commandos, i don't think that's the error, because closing php tag "?>" in that particular line implies semicolon. To TS: Check your quotes, they look funny, replace all “ and †with " Do that with single quotes too. Further, you will probably get header warning, "headers already sent", you need to put session_start(); before any other output.
now that error is removed but its giving new error Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at E:\xampplite\htdocs\practice\test\moviesite.php:3) in E:\xampplite\htdocs\practice\test\moviesite.php on line 4 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\xampplite\htdocs\practice\test\moviesite.php:3) in E:\xampplite\htdocs\practice\test\moviesite.php on line 4 Sorry but you don't have permission to view this page, you loser! I have changed quotes to ". now my code is following <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <?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 fav site is <?php echo $_REQUEST['favmovie']; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php echo "my fav movie is "; echo $_REQUEST['favmovie'] ; $movierate=5; echo "my movierate for this movie is "; echo $movierate; ?> </body> </html> Please help me to solve this error.
The error tells you EXACTLY what the problem is (and this problem has been explained hundreds of times on this forum before). If you output a single character (even a newline) before sending headers, you will get this error. ALL headers need to be sent BEFORE ANY other output. Cookies are sent in the headers and sessions are managed by cookies. Therefore, call your session_start BEFORE your doctype output.
Hogan_h just told you how to fix that problem before you even posted it. Please read through this topics replies.