EDIT: The problem was fixed. I had to remove all indentation in the file.
I'm trying to return a JSON array from my server but the PHP keeps throwing this error:
[15-Jun-2015 22:46:59 UTC] PHP Parse error: syntax error, unexpected '{' in /home/user/public_html/backend/xstudio/get_all_mods.php on line 10
I've seen many people have problems like this where they're missing a semicolon or something but I just can't find the problem... Here is my code:
<?php
$response = array("success", "message", array()=>"mods");
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/db_connect.php');
$db = new DB_CONNECT();
$result = mysql_query("SELECT *FROM mods") or die(mysql_error());
if(mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
$mod = array();
$mod["mod_id"] = $row["mod_id"];
$mod["name"] = $row["name"];
$mod["author"] = $row["author"];
$mod["description"] = $row["description"];
$mod["download"] = $row["download"];
$mod["picture"] = $row["picture"];
$mod["created_at"] = $row["created_at"];
$mod["updated_at"] = $row["updated_at"];
array_push($response["mods"], $mod);
}
$response["success"] = 1;
echo json_encode($response);
} else {
$response["success"] = 0;
$response["message"] = "No mods found";
echo json_encode($response);
}
?>
Any and all help is appreciated, thanks!