php(json_encode returns null)! : <p>i am trying to write kind of user client server using java(android) and php.i asked this question before but no one answer my question.my database is utf8.i am nearly for two weeks trying to solve the problem of this part but i couldn't.
the problem is:
I have one array that it contains my database rows and when you use:</p>

<pre><code>print_r ($jasonData);
</code></pre>

<p>and give an output from that you can see it's not null but when i use:</p>

<pre><code>echo json_encode($jasonData);
</code></pre>

<p>it shows null and i can't understand why it can happens.
i've searched in stack before and i saw every related questions.but they didn't work for me.
also the</p>

<pre><code>echo json_last_error();
</code></pre>

<p>shows 0.</p>

<pre><code>&lt;?php 
$hostname = "localhost";
$dbname = "amir";
$dbpass = "123456";
$con = new mysqli($hostname,$dbname,$dbpass,'amir');

$jasonData = array();
$sql="select Username , Password from User_Login ";

if($result = $con-&gt;query($sql)){
while($row = $result-&gt;fetch_row()){
$jasonData[] = array_map('utf8_encode', $row);
/*
print $row[0];
print $row[1];
*/
}
}
print_r ($jasonData);
echo json_encode($jsonData);
print json_last_error();
$con-&gt;close();  
</code></pre>

<p>If anyone knows why that happens,please give me an advice how can i fix that.</p>
