 <p>you cant echo string in php file and introduce as JSONObject in android.</p> <p>all error and message must be in json array and just json array showed in php file .</p> <p>i suggest this :</p> <pre><code> &lt;?php $host='localhost'; $uname='amodbina0106'; $pwd='Amodbina200'; $db="kezin_king"; $result = array(); $con=mysqli_connect("localhost","amodbina0106","Amodbina200","kezin_king"); if ($con-&gt;connect_error) { $result['status'] = false; $result['message'] = 'server lost'; die(json_encode($result)); } $username = $_GET['username']; $password = $_GET['password']; $flag['code']=0; if($name == '' || $username == '' || $password == '' || $email == ''){ $result['status'] = false; $result['message'] = 'All field required'; } else{ $sql=mysql_query("insert into sample values('$id','$name') ",$con); if(mysqli_query($con,$sql)) { $flag['code']=1; $result['status'] = true; $result['message'] = 'hi'; } print(json_encode($result)); mysql_close($con); } ?&gt; </code></pre>