php - how to fix org.json.JSONException: Value <br><table of type java.lang.String cannot be converted to JSONArray -


can please me fix below error ?

07-07 18:36:54.049: e/pass 1(22845): connection success 07-07 18:36:54.194: e/pass 2(22845): connection success 07-07 18:36:54.194: e/fail 3(22845): org.json.jsonexception: value

here below code

    public void postdata(string valueiwanttosend) {         // create new httpclient , post header         arraylist<namevaluepair> namevaluepairs = new arraylist<namevaluepair>();          namevaluepairs.add(new basicnamevaluepair("id",id));         namevaluepairs.add(new basicnamevaluepair("name",name));          try         {         httpclient httpclient = new defaulthttpclient();             httppost httppost =new httppost("http://justedhak.comlu.com/insert.php");             httppost.setentity(new urlencodedformentity(namevaluepairs));             httpresponse response = httpclient.execute(httppost);              httpentity entity = response.getentity();             = entity.getcontent();             log.e("pass 1", "connection success ");     }         catch(exception e)     {             log.e("fail 1", e.tostring());             toast.maketext(getapplicationcontext(), "invalid ip address",             toast.length_long).show();     }               try         {             bufferedreader reader = new bufferedreader             (new inputstreamreader(is,"iso-8859-1"),8);             stringbuilder sb = new stringbuilder();             while ((line = reader.readline()) != null)         {                 sb.append(line + "\n");             }             is.close();             result = sb.tostring();         log.e("pass 2", "connection success ");     }         catch(exception e)     {             log.e("fail 2", e.tostring());     }               try         {             jsonarray jarray = new jsonarray(result);             stringbuilder sb = new stringbuilder();             for(int i=0;i<jarray.length();i++){                 jsonobject json_data = jarray.getjsonobject(i);                 log.i("log_tag","id: "+json_data.getint("id")+                         ", name: "+json_data.getstring("name"))                 ;         log.e("pass 3", "connection success ");     }}         catch(exception e)     {             log.e("fail 3", e.tostring());     }    }} 

}

edit

here php

<?php     $host='mysql12.000webhost.com';     $uname='a6901827_moudiz';     $pwd='***';     $db="a6901827_justed";       $con = mysql_connect($host,$uname,$pwd) or die("connection failed");     mysql_select_db($db,$con) or die("db selection failed");      $id=$_request['id'];     $name=$_request['name'];      $flag['code']=0;      $r=mysql_query("insert samle values('$id','$name') ",$con)      echo json_encode(1); mysql_close($con); ?> 

this error

07-07 20:13:52.300: e/2(8837): <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><font face='arial' size='1' color='#000000'><b>php error message</b></font></td></tr></table><br /> 07-07 20:13:52.300: e/2(8837): <b>parse error</b>:  syntax error, unexpected t_echo in <b>/home/a6901827/public_html/insert.php</b> on line <b>17</b><br /> 07-07 20:13:52.300: e/2(8837): <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='arial' size='1' color='#000000'>free web hosting</font></a></div></td></tr></table> 07-07 20:13:52.300: e/fail 3(8837): org.json.jsonexception: value <br><table of type java.lang.string cannot converted jsonarray 

so response

    <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><font face='arial' size='1' color='#000000'><b>php error message</b></font></td></tr></table><br /> <b>warning</b>:  mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: access denied user 'a6901827'@'localhost' (using password: no) in <b>/home/a6901827/public_html/insert.php</b> on line <b>6</b><br /> <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='arial' size='1' color='#000000'>free web hosting</font></a></div></td></tr></table><br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><font face='arial' size='1' color='#000000'><b>php error message</b></font></td></tr></table><br /> <b>warning</b>:  mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: access denied user 'a6901827'@'localhost' (using password: no) in <b>/home/a6901827/public_html/insert.php</b> on line <b>7</b><br /> <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='arial' size='1' color='#000000'>free web hosting</font></a></div></td></tr></table><br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><font face='arial' size='1' color='#000000'><b>php error message</b></font></td></tr></table><br />  <b>warning</b>:  mysql_select_db() [<a href='function.mysql-select-db'>function.mysql-select-db</a>]: link server not established in <b>/home/a6901827/public_html/insert.php</b> on line <b>7</b><br /> <br><table border='1' cellpadding='2' bgcolor='#ffffdf' bordercolor='#e8b900' align='center'><tr><td><div align='center'><a href='http://www.000webhost.com/'><font face='arial' size='1' color='#000000'>free web hosting</font></a></div></td></tr></table>could not connect: access denied user 'a6901827'@'localhost' (using password: no) 

if not tell can see here https://jsfiddle.net/91dk9p95/

answer easy, access denied error returned database. check credentials , try again.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -