Array from database not working with json_encode
<p>If I change the array <code>$foo</code> to <code>$foo = array("one","two","three","four","five");</code> 
Then javascript will show me drop down lists when as i type the value, but when I am getting array $foo from database, the form is silent. </p>

<p>PHP:</p>

<pre><code>&lt;?php 

mysql_connect("localhost","root","") or die(mysql_error());
mysql_select_db("xxxx") or die(mysql_error());

$array = mysql_query("SELECT * FROM clients");
while($row = mysql_fetch_array($array)) {
$foo = $row['company'] ; }

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

<p>JS:</p>

<pre><code>&lt;script&gt;
$(function() {
    var availableTags = &lt;?php echo json_encode( $foo ); ?&gt;;
    $( "#tags" ).autocomplete({
        source: availableTags
    });
});
&lt;/script&gt;
</code></pre>

<p>HTML:</p>

<pre><code>&lt;label for="tags"&gt;Tags:&lt;/label&gt;
&lt;input id="tags" name="field"/&gt;
</code></pre>
