www.webdeveloper.com
Results 1 to 10 of 10

Thread: Newbie synthax question

  1. #1
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101

    Newbie synthax question

    Hello !!!!
    I'm trying to do a php autentication with sessions, and, just after I type in the username and password and click submit, I get a :
    Parse error: parse error, unexpected '<' in /var/www/free.fr/a/d/enfantsdelo/protected/edito.php on line 7

    here is the page edito.php :
    PHP Code:
    <?php
    session_start
    ();
    if(
    $login_username=="") {
    Header("Location: login.htm");
    } else {
    ?>
     // curiously, that's the line 7.
        <HTML> 
        <HEAD> 
        <TITLE>Secret Stuff</TITLE> 
        </HEAD> 
        <BODY> 
        <H1>SECRET!</H1> 
        <P>This is a secret message.</P> 
        </BODY> 
        </HTML> 
    <?
    }
    ?>
    I tested different synthax, one involving echo and no break in the php code. It looked like that :
    PHP Code:
    <?php
    session_start
    ();
    if(
    $login_username=="") {
    Header("Location: login.htm");
    } else {
    echo 

     // line 7
        <HTML> 
        <HEAD> 
        <TITLE>Secret Stuff</TITLE> 
        </HEAD> 
        <BODY> 
        <H1>SECRET!</H1> 
        <P>This is a secret message.</P> 
        </BODY> 
        </HTML> 

        '


    }
    ?>
    I got the same error message.
    What have I done wrong ?

  2. #2
    Join Date
    Dec 2003
    Location
    Netherlands
    Posts
    642
    try double quotes...

  3. #3
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    I tried. It doesn't work...

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,537
    Header() should be lower-case: header(). However, I wouldn't think that would cause the error message you are receiving. Hmmmm.....assuming $login_username is supposed to be a session variable, I would check it like this:
    PHP Code:
    <?php
    session_start
    ();
    if(!isset(
    $_SESSION['login_username']) or $_SESSION['login_username'] == "") {
      
    header("Location: login.htm");
    }
    else {
    ?>
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    PHP's predefined functions are incase sensitive, it's perfectly safe to use upper or lower case, thus that's not the problem.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,537
    Quote Originally Posted by scragar
    PHP's predefined functions are incase sensitive, it's perfectly safe to use upper or lower case, thus that's not the problem.
    Really? I have to admit I just assumed they were case-sensitive, since PHP's syntax is so similar to C and Perl.
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    http://scragar.mybesthost.com/new.php

    I acidentaly found echo was incasesensitive, then I tried various others, and they all are(every one I've tested).

    try the link a different time, my test host went down again when I tried editing it...
    Last edited by scragar; 04-29-2005 at 08:57 AM.

  8. #8
    Join Date
    Aug 2004
    Location
    Switzerland
    Posts
    1,101
    I'm ashamed... I'm really ashamed, and sooooo sorry !!!
    I'm working on two sites at the moment. And I tested that one in my test server, the one which doesn't have any mysql database...
    I tried it in my real website, and it didn't work for another stupid reason. But then, when I corrected it and tried again, I didn't realised I had corrected it only on the test server...
    Don't hit me, please !!!
    Sorry for making you lose your time like that, I feel really stupid...

  9. #9
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    don't worry about it, it's an honest mistake.

    And NogDog's learnt something.

  10. #10
    Join Date
    Mar 2005
    Location
    St. Louis Metro East
    Posts
    71
    Quote Originally Posted by Ness_du_Frat
    I'm ashamed... I'm really ashamed, and sooooo sorry !!!
    I'm working on two sites at the moment. And I tested that one in my test server, the one which doesn't have any mysql database...
    I tried it in my real website, and it didn't work for another stupid reason. But then, when I corrected it and tried again, I didn't realised I had corrected it only on the test server...
    Don't hit me, please !!!
    Sorry for making you lose your time like that, I feel really stupid...
    Happens to all of us occasionally. At least you didn't overwrite the new file with the old one, I have done that before, and it really sucks!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles