Encoding an array with JSON; getting "illegal offset type" error
<p>I am trying to use a getJSON method in jquery to retrieve a dynamic array.  I am getting an "illegal" offset error trying to encode my dynamic array.  Here is the server side code (I am confident the javascript is correct because when I remove the query it runs fine):</p>

<pre><code>&lt;?php 
session_start();
require_once "database.php";
db_connect();
require_once "auth.php";
$current_user = current_user();
include_once("config.php");

$westcoast_id = $_GET['westcoast_id'];

$westcoast_array = array();


 $query = "SELECT city, state FROM users GROUP BY city";
 $result = mysql_query($query) or die(mysql_error());
 while($row = mysql_fetch_array($result)){

if($row['city'] != '' &amp;&amp; $row['state'] != '') {
    $westcoast_array[$row] = "location:".$row['city'].", ".$row['state'].", stopover:true";


   }

}

$data = array($westcoast_id, $westcoast_array);

echo json_encode($data);


?&gt;
</code></pre>

<p>The illegal offset is in reference to the line:</p>

<pre><code>$westcoast_array[$row] = "location:".$row['city'].", ".$row['state'].", stopover:true";
</code></pre>

<p>I cannot see what the issue is.  Thank you for your help!</p>
