I'm getting this error:
Parse error: syntax error, unexpected '[' in /home/cjliu49/public_html/index.php on line 10
on the below code, when I declare '$links = [ ];':
<?php
// configuration
require("../includes/config.php");
$rows = query("SELECT link, description, DATE(timestamp) AS timestamp FROM links WHERE id = ? ORDER BY DATE(timestamp) DESC, timestamp ASC", $_SESSION["id"]);
$listtitle = query("SELECT title FROM users WHERE id = ?", $_SESSION["id"]);
$links = [];
foreach ($rows as $row)
{
$links[] = [
"link" => $rows["link"],
"description" => $rows["description"],
"timestamp" => $rows["timestamp"]
];
}
render("linklist.php", ["title" = $listtitle, "links" => $links]);
?>
Am I declaring an empty array variable incorrectly? I also tried '$links[ ] = [ ];' and got the same error. Or is the error that the server isn't recognizing PHP code?
Thanks!