Arrays in php & javascript syntax issues
<p>I have got my self confused on how to construct arrays correctly in PHP prior to my json encode to check them in javascript.</p>

<p>I'm trying to store an array of objects with their grid reference (x,y)</p>

<p>So i do this in php:</p>

<pre><code>    $get = mysql_query("SELECT x,y,sid FROM $table WHERE uid='1'") or die(mysql_error());
    while($row = mysql_fetch_assoc($get)) {
        $data[$row['x'].$row['y']] = $row['sid'];
    }
//print_r($data);
$data = json_encode($data);
</code></pre>

<p>In javascript i then try to check if a object exists on a given co-ordinate so i try this:</p>

<pre><code> for (i=0;i&lt;tilesw;i++){ //horizontal   
  for (j=0;j&lt;tilesh;j++){ // vertical

        if(sdata[i.j]){
            alert(sdata[i.j][sid]); 
        }
          }
        }
</code></pre>

<p>sdata is my array after json encode.</p>

<p>My json encode looks like this:</p>

<pre><code> {"44":"0","21":"0"}
</code></pre>

<p>Problem is i get :
Uncaught SyntaxError: Unexpected token ] on the alert line.</p>

<p>Also is my approach correct or is there a better way to construct my array?</p>
