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?
Answer
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.
No comments:
Post a Comment