简体   繁体   中英

Syntax Error Unexpected

> Blockquote
I'm getting an error:

     syntax error, unexpected ')', expecting ']'  on line 7.

I was attempting to correct the previous error of " PHP Fatal error: Call to undefined function session_is_registered()

Blockquote

    session_start();
        if(!isset($_SESSION['user'))
            session_register("user");
            $_SESSION['user'] = array();
        }
        if(!session_is_registered('cart')) {
            session_register("cart");
            $_SESSION['cart'] = array();
        }
        define("USERID", userId());

        if($secureMode == "ON" && $_SERVER['HTTPS'] != "on")
            die(header("Location: ".SELF));

        if($secureMode != "ON" && $_SERVER['HTTPS'] == "on")
            die(header("Location: ".SELF));

        if($_GET['f'] == "user") $_SESSION['filterUser'] = 1;
        elseif($_GET['f'] == "all") $_SESSION['filterUser'] = false;

        if($_SESSION['filterUser']) $sortBy = "byUser";
        else $sortBy = "byAll";

Update: PHP Fatal error: Call to undefined function session_register() in line 8

session_register("user");

if(!isset($_SESSION['user'))

Should be

if(!isset($_SESSION['user']))

Notice the closing square bracket.

You also need a { after that.

a compiled version of carl and bhupendra's answers:

session_start();
if(!isset($_SESSION['user'])) {
    session_register("user");
    $_SESSION['user'] = array();
}

I removed session_register("user"); and it brought the website back where all contents and images display. Thanks for everyone's input.

需要{ if(!isset($_SESSION['user']))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM