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?

TimWolla
  • 31,849
  • 8
  • 63
  • 96
wateraura
  • 331
  • 1
  • 2
  • 8

1 Answers1

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.

TimWolla
  • 31,849
  • 8
  • 63
  • 96
  • 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.) – wateraura May 02 '15 at 22:04