I have modified my code over a couple of hours and I just cannot seem to parse value from android and use it in php, I alway get JSONarray cannot be converted to JSONobject.
<?php
include 'config.php';
$con=mysql_connect("$servername", "$username", "$password")or die("cannot connect");
mysql_select_db("$dbname")or die("cannot select DB");
if( isset($_POST["json"]) ) {
$value = $_POST["json"];
$decoded_value = json_decode($value);
$sql = "SELECT * from table WHERE Code = '".$decoded_value->{'msg'}."'";
$result = mysql_query($sql);
$json = array();
if(mysql_num_rows($result)){
while($row=mysql_fetch_assoc($result)){
$json['myarray'][]=$row;
}
}
mysql_close($con);
echo json_encode($json);
}
?>