android - Error parsing data org.json.JSONException: End of input at character 0 of -


i creating android application, in there search module user enters data send server , server sends output user , displayed in form of table.

my problem getting error

  06-02 00:08:43.971  19902-20586/com.diamond.traders w/singleclientconnmanager﹕ invalid use of singleclientconnmanager: connection still allocated.     make sure release connection before allocating one. 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ org.apache.http.client.httpresponseexception: not found 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.basicresponsehandler.handleresponse(basicresponsehandler.java:71) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.basicresponsehandler.handleresponse(basicresponsehandler.java:59) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:657) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:627) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ org.apache.http.impl.client.abstracthttpclient.execute(abstracthttpclient.java:616) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ com.diamond.traders.search_result$getdatafromdb_searchresult.getdatafromdb(search_result.java:676) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ com.diamond.traders.search_result$1.run(search_result.java:80) 06-02 00:08:43.991  19902-20586/com.diamond.traders w/system.err﹕ @ java.lang.thread.run(thread.java:811) 06-02 00:08:43.991  19902-20586/com.diamond.traders i/system.out﹕ exception : not found 06-02 00:08:43.991  19902-19902/com.diamond.traders e/log_tag﹕ error parsing data org.json.jsonexception: end of input @ character 0 of 

here networking code , here link complete code. sorry can't add here long.

public class getdatafromdb_searchresult {          public string getdatafromdb() {               try {                  httpclient = new defaulthttpclient();                 httppost = new httppost("http://192.168.0.106/test/search1.php"); // make sure url correct.                 //add data                 namevaluepairs = new arraylist<namevaluepair>(2);                 // use same variable name posting i.e android side variable name , php side variable name should similar,                 namevaluepairs.add(new basicnamevaluepair("carat1", strcolor1.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("carat2", strcolor2.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("color1", strclarity1.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("color2", strclarity2.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("cut1", strcut1.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("cut2", strcut2.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("shape1", strshape1.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("shape2", strshape2.tostring().trim()));                 namevaluepairs.add(new basicnamevaluepair("stones", strstone.tostring().trim()));                   // $edittext_value = $_post['edittext_value'];                  httppost.setentity(new urlencodedformentity(namevaluepairs));                 //execute http post request                 response = httpclient.execute(httppost);                  responsehandler<string> responsehandler = new basicresponsehandler();                 final string response1 = httpclient.execute(httppost, responsehandler);                 system.out.println("response : " + response1);              } catch (exception e) {                  system.out.println("exception : " + e.getmessage());             }              return response1.trim();          }     } 

here server side code

<?php $hostname_localhost ="localhost"; $database_localhost ="testdb"; $username_localhost ="root"; $password_localhost =""; $localhost = mysql_connect($hostname_localhost,$username_localhost,$password_localhost) or trigger_error(mysql_error(),e_user_error);   mysql_select_db($database_localhost, $localhost);  $carat1 = $_post['carat1']; $carat2 = $_post['carat2']; $color1 = $_post['color1']; $color2 = $_post['color2']; $cut1 = $_post['cut1']; $cut2 = $_post['cut2']; $shape1 = $_post['shape1']; $shape2 = $_post['shape2']; $stones = $_post['stones'];    $query_search ="select * search1  carats = $carat1 , carats = $carat2 ,  color = '$color1' or color =  '$color2' ,   cut = '$cut1' or cut = '$cut2' ,   shape = '$shape1' or shape = '$shape2' ,   stone ='$stones'";  $query_exec = mysql_query($query_search) or die(mysql_error());       while($row=mysql_fetch_assoc($query_exec))             $json_output[]=$row;       echo json_encode($json_output);      mysql_close();  ?> 

edit: output server.

06-02 00:02:08.229  19428-19481/com.diamond.traders i/system.out﹕ [{"id":"1","product_code":"sdfsd","shaps":"fsdfsd","pair":"fsdf","carats":"sdgfdhn","color":"gnfgng","clarity":"jmf","service":"fgnfgnf","polish":"gnfg","symetric":"nfgnfg","tables":"nfgjkrtyr","measurments":"tjrt","flourscne":"jrtjr","description":"tjrtjgmgv","certificated":"mvbmv","ccode":"bmvb","cut":"kmty","total":"yttynyt","file":"tyfjfjgjfg"},{"id":"2","product_code":"fgn","shaps":"fgmkyh","pair":"wqqfwfw","carats":"fsfsdsdf","color":"gsdfwe","clarity":"fsdfsdf","service":"sdfs","polish":"dfsd","symetric":"fsdfs","tables":"dfsdf","measurments":"sdf","flourscne":"sdfsd","description":"fsdfsdd","certificated":"sfs","ccode":"dfsd","cut":"fsdf","total":"sdf","file":"sdf"},{"id":"3","product_code":"xfcbxcb","shaps":"xcbx","pair":"cbxcb","carats":"xcb","color":"xcbx","clarity":"cxcbxc","service":"xcb","polish":"xcbx","symetric":"cbxc","tables":"bxcb","measurments":"xcbxc","flourscne":"b","description":"xcbxcb","certificated":"xcbx","ccode":"cbx","cut":"cbxc","total":"bxc","file":"b"},{"id":"4","product_code":"xcb","shaps":"xcb","pair":"xcbxc","carats":"bxc","color":"bxc","clarity":"bxc","service":"bxc","polish":"xc","symetric":"bxcb","tables":"xcbx","measurments":"cbx","flourscne":"cbx","description":"cbxcbxcb","certificated":"xcbxc","ccode":"bxc","cut":"bxcb","total":"xcb","file":"xc"}] 

looks you're not getting return response correctly. try this...

httpresponse response = defaulthttpclient.execute(httppost); inputstream data = response.getentity().getcontent(); 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -