SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error - can't see what it is

    I'm getting a parse error from line 6 of this script and for the life of me cannot see where the error is.....it's about where the if statement starts...

    Can anyone enlighten me?

    PHP Code:
    <?php //accesscontrol.php Checks for valid users

        
    include("functions.php");
        
        
    session_start();
        
    ****if (!session_is_registered("Authen")*and*!isset($uid)) {
    *********// login form (user must type $uid and $pwd)
            
    header("Location: [url]http://mysite.com/some_page.php[/url]");
            exit;
    ****}

  2. #2
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ignore that target blank stuff...that is not in the script...

  3. #3
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    change following line
    PHP Code:
     header("Location: <a href="http://mysite.com/some_page.php" target="_blank">[url]http://mysite.com/some_page.php[/url]</a>"); 
    to

    PHP Code:
     header('Location: <a href="http://mysite.com/some_page.php" target="_blank">[url]http://mysite.com/some_page.php[/url]</a>'); 
    Reason: if you are using " in your double quoted string, you should either escape them or use single quotation for your string.

  4. #4
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that, but it doesn't work. I get the same error. Actually I am bit surprised to hear about single quotes as I use the header function a lot and I have always used double quotes without error...

  5. #5
    SitePoint Member
    Join Date
    Mar 2001
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm not really sure but maybe ...

    change

    PHP Code:
    if (!session_is_registered("Authen") and !isset($uid)) { 
    to

    PHP Code:
    if (!session_is_registered("Authen") && !isset($uid)) { 
    ----------------------------
    http://mmorpgforums.phpstyle.com

  6. #6
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    did u check how to use header with location on php.net?

    http://www.php.net/manual/en/function.header.php

    PHP Code:
    header("Location: [url]http://www.php.net/[/url]"); /* Redirect browser 
    exit;   /* Make sure that code below does  not get executed when we redirect. */ 

  7. #7
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still get the same parse error on line 6 with the && instead of and.

    Did check out the header function on the php manual but they always use double quotes. I copied the header stuff from a php book. Never had any errors...

  8. #8
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the entire code. Maybe you can see something I am missing completely!

    PHP Code:
    <?php //accesscontrol.php Checks for valid users

        
    include("functions.php");
        
        
    session_start();
        
    ****if (!session_is_registered("Authen")*and*!isset($uid));*{
    *********// login form (user must type $uid and $pwd)
            
    header("Location: http://mysite.com/some_page.php");
            exit;
    ****}

    ****if*(!session_is_registered("Authen")*and*isset($uid))

    ****{
    ********dbConnect("some_db");
            
    $sql*=*"SELECT***FROM*site_registration*WHERE*username*= '$uid'*AND*password*=*PASSWORD('$pwd')";
    ********$result*=*mysql_query($sql);

    ********if*(!$result)*{*
                error
    ("Cannot query database");**
                
    exit;
                
            }

    ********if*(mysql_num_rows($result)*==1)*

              
    //if found uid and pwd in database set $Authen=$uid as session variable and everytime only check $Authen,
              //if exist then allow user to view page

    ********{
    ************$Authen*=*$uid;
    *************session_register("Authen");
    ********}

    ****if*(mysql_num_rows($result)*==*0)
    ********{
    ************access_denied();*//print some error
    ************error("Cannot find any record");
                exit;
    ********}
    ****}****

    ?>

  9. #9
    SitePoint Guru
    Join Date
    Jan 2001
    Location
    Alkmaar, Netherlands
    Posts
    710
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if (!session_is_registered("Authen") and !isset($uid)); { 
    do you see the semi colon at the end of if?
    remove it and try again

  10. #10
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, put that in earlier when I was trying to find out what was breaking.

    After removing it I get the same error.

    Interestingly, if I remove the first 2 if statements the error still appears on line 6.

  11. #11
    SitePoint Addict
    Join Date
    Jan 2002
    Location
    Norway
    Posts
    219
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is the entire code. Maybe you can see something I am missing completely!

    PHP Code:
    <?php //accesscontrol.php Checks for valid users

        
    include("functions.php");
        
        
    session_start();
        
    ****if (!session_is_registered("Authen")*and*!isset($uid));*{
    *********// login form (user must type $uid and $pwd)
            
    header("Location: http://mysite.com/some_page.php");
            exit;
    ****}

    ****if*(!session_is_registered("Authen")*and*isset($uid))

    ****{
    ********dbConnect("some_db");
            
    $sql*=*"SELECT***FROM*site_registration*WHERE*username*= '$uid'*AND*password*=*PASSWORD('$pwd')";
    ********$result*=*mysql_query($sql);

    ********if*(!$result)*{*
                error
    ("Cannot query database");**
                
    exit;
                
            }

    ********if*(mysql_num_rows($result)*==1)*

              
    //if found uid and pwd in database set $Authen=$uid as session variable and everytime only check $Authen,
              //if exist then allow user to view page

    ********{
    ************$Authen*=*$uid;
    *************session_register("Authen");
    ********}

    ****if*(mysql_num_rows($result)*==*0)
    ********{
    ************access_denied();*//print some error
    ************error("Cannot find any record");
                exit;
    ********}
    ****}****

    ?>


Bookmarks

Posting Permissions

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