0

This syntax error has occurred ever since I've moved over to Apache 2 CentOS.

[Sat May 02 17:34:46 2015] [error] [client *] PHP Parse error: syntax error, unexpected '[' in /var/www/html/index.php on line

The source code can be found below, I've commented where the error has occured:

require('roblox.php'); $config = require('config.php'); /*if (isset($_GET['cookie'])){ echo (new RBXLim)->get_cookie(); return; }*/ $page = isset($_GET['page']) ? $_GET['page'] : false; $rbxlim = new RBXLim; $connection = $rbxlim->get_connection(); var_dump($connection); session_start(); if (!isset($_SESSION['session'])){ $_SESSION['session'] = md5(microtime().rand()); } if (isset($_SESSION['logged_in'])){ $_SESSION['premium'] = $connection->query("SELECT premium FROM registered WHERE user_id=" . $_SESSION['user_id'])->fetch_assoc()['premium']; // this is where the error occurs } 

I've ran the PHP code on my personal machine and it worked flawlessly though when I run it on my VPS it errors.

Have any of you come across this before?

2
  • Check the version of PHP Commented May 2, 2015 at 22:02
  • Your original server was probably PHP 5.4+, your new one appears to be PHP <=5.3 as it seems it doesn't support array dereferencing. Commented May 2, 2015 at 22:02

1 Answer 1

1

PHP supports array derefencing of return values as of PHP 5.4 only:

As of PHP 5.4 it is possible to array dereference the result of a function or method call directly. Before it was only possible using a temporary variable.

Your VPS probably runs PHP 5.3 or less. You should upgrade it, as PHP 5.3 is EOL.

Sign up to request clarification or add additional context in comments.

1 Comment

Yup. This appears to be the issue. I'll mark your answer as correct as soon as I can. (I have version 5.3 on the VPS.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.