1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

program error

Discussion in 'PHP' started by kharearch, Jan 4, 2008.

  1. #1
    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.
     
    kharearch, Jan 4, 2008 IP
  2. commandos

    commandos Notable Member

    Messages:
    3,648
    Likes Received:
    329
    Best Answers:
    0
    Trophy Points:
    280
    #2
    <title>my fav site is <?php echo $_REQUEST['favmovie']; ?></title>
     
    commandos, Jan 4, 2008 IP
  3. hogan_h

    hogan_h Peon

    Messages:
    199
    Likes Received:
    30
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    hogan_h, Jan 4, 2008 IP
  4. kharearch

    kharearch Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    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.
     
    kharearch, Jan 5, 2008 IP
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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.
     
    TwistMyArm, Jan 5, 2008 IP
  6. Millar

    Millar Peon

    Messages:
    334
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hogan_h just told you how to fix that problem before you even posted it. Please read through this topics replies.
     
    Millar, Jan 5, 2008 IP
    hogan_h likes this.