I have a problem with my arrays in JavaScript. I can't seem to get the value correctly.
I create my array in PHP like this:
$data = Array();
$get = mysql_query("SELECT x,y,sid FROM table WHERE uid='1'");
while($row = mysql_fetch_assoc($get)){
$data[$row['x']] = Array();
$data[$row['x']][$row['y']] = $row['sid'];
}
$data = json_encode($row)
EDIT The json_encode comes out as "false" /EDIT
I then assigned this $data to a JS variable as sdata.
So then i try to get the value in JS but its not working. I get an undefined error.
This is my Javascript:
var i = 1;
var j = 5;
if(sdata["x"] == i && sdata["y"] == j){
alert(sdata["x"]["y"]["sid"]);
}
Its meant to alert me the value of "sid" but i get: Undefined
Any ideas where my mistake is?