Handling array value in JS
<p>I have a problem with my arrays in JavaScript. I can't seem to get the value correctly.</p>

<p>I create my array in PHP like this:</p>

<pre><code>$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)
</code></pre>

<p>EDIT The json_encode comes out as "false" /EDIT</p>

<p>I then assigned this $data to a JS variable as sdata.</p>

<p>So then i try to get the value in JS but its not working. I get an undefined error.</p>

<p>This is my Javascript:</p>

<pre><code>var i = 1;
var j = 5;
    if(sdata["x"] == i &amp;&amp; sdata["y"] == j){
    alert(sdata["x"]["y"]["sid"]);
            }
</code></pre>

<p>Its meant to alert me the value of "sid" but i get:
Undefined     </p>

<p>Any ideas where my mistake is?</p>
