android - The target server failed to respond! why this error in 000webhost? -


i using 000webhost sample db, can me solve this? ran application both in real object , on emulator.

i getting error:

07-02 07:17:27.120: w/system.err(2675): org.apache.http.nohttpresponseexception: target server failed respond 07-02 07:17:27.120: w/system.err(2675):     @ org.apache.http.impl.conn.defaultresponseparser.parsehead(defaultresponseparser.java:85) 

this json:

public class jsonparser {     static inputstream = null;     static jsonobject jobj = null;     static string json = "";      // constructor     public jsonparser() {      }      public jsonobject makehttprequest(string url, string method,             list<namevaluepair> params) {          // making http request         try {              // check request method             if(method == "post"){                  defaulthttpclient httpclient = new defaulthttpclient();                 httppost httppost = new httppost(url);                 httppost.setentity(new urlencodedformentity(params));                  httpresponse httpresponse = httpclient.execute(httppost);                 httpentity httpentity = httpresponse.getentity();                 = httpentity.getcontent();              }else if(method == "get"){                 // request method                 defaulthttpclient httpclient = new defaulthttpclient();                 string paramstring = urlencodedutils.format(params, "utf-8");                 url += "?" + paramstring;                 httpget httpget = new httpget(url);                  httpresponse httpresponse = httpclient.execute(httpget);                 httpentity httpentity = httpresponse.getentity();                 = httpentity.getcontent();             }                      } catch (unsupportedencodingexception e) {             e.printstacktrace();         } catch (clientprotocolexception e) {             e.printstacktrace();         } catch (ioexception e) {             e.printstacktrace();         }          try {             bufferedreader reader = new bufferedreader(new inputstreamreader(                     is, "iso-8859-1"), 8);             stringbuilder sb = new stringbuilder();             string line = null;             while ((line = reader.readline()) != null) {                 sb.append(line + "\n");             }             is.close();             json = sb.tostring();         } catch (exception e) {             log.e("buffer error", "error converting result " + e.tostring());         }          // try parse string json object         try {             //log.d("response string",json);             jobj = new jsonobject(json);         } catch (jsonexception e) {             log.e("json parser", "error parsing data " + e.tostring());         }          // return json string         return jobj;      } } 

this java:

public class signup extends activity {      private progressdialog pdialog;      jsonparser jsonparser = new jsonparser();      string name,email,password,gender,age,phone,message,successvalue;       button signup,cancel;      edittext txtname,txtemail,txtpassword,txtage,txtphone;      radiogroup gendergroup;     radiobutton genderbutton;       private static final string url_create_user = "http://mysql14.000webhost.com/sign_up.php";     private static final string tag_success = "success";  //   private static final string tag_message = "message";      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_sign_up);          txtname = (edittext)findviewbyid(r.id.txtname);         txtemail = (edittext)findviewbyid(r.id.txtemail);         txtpassword = (edittext)findviewbyid(r.id.txtpassword);         txtage = (edittext)findviewbyid(r.id.txtage);         txtphone = (edittext)findviewbyid(r.id.txtphone);           signup = (button)findviewbyid(r.id.btnsignup);         cancel = (button)findviewbyid(r.id.btncancel);          addlisteneronbutton();     }      private void addlisteneronbutton() {          // todo auto-generated method stub          signup.setonclicklistener(new onclicklistener() {              @override             public void onclick(view v) {                  gendergroup = (radiogroup)findviewbyid(r.id.gender);                 int selectedid = gendergroup.getcheckedradiobuttonid();                 genderbutton = (radiobutton)findviewbyid(selectedid);                  // todo auto-generated method stub                  name = txtname.gettext().tostring();                  email = txtemail.gettext().tostring();                  password = txtpassword.gettext().tostring();                  gender = genderbutton.gettext().tostring();                  age = txtage.gettext().tostring();                  phone = txtphone.gettext().tostring();      //          toast.maketext(getapplicationcontext(), name + email + password + gender + age + phone, toast.length_short).show();                  if (name.trim().equals("") || email.trim().equals("") || password.trim().equals("") || gender.trim().equals("") || age.trim().equals("") || phone.trim().equals(""))                 {                        toast.maketext(getapplicationcontext(), "please enter values", toast.length_long).show();                 }                 else {                     new createnewuser().execute();                   }              }         class createnewuser extends asynctask<string, string, string>{                   @override                 protected void onpreexecute() {                     super.onpreexecute();                     pdialog = new progressdialog(signup.this);                     pdialog.setmessage("creating user...");                     pdialog.setindeterminate(false);                     pdialog.setcancelable(false);                     pdialog.show();                 }                  @override                 protected string doinbackground(string... args) {                     // todo auto-generated method stub                     list<namevaluepair> params = new arraylist<namevaluepair>();                      params.add(new basicnamevaluepair("name", name));                     params.add(new basicnamevaluepair("email", email));                     params.add(new basicnamevaluepair("password", password));                     params.add(new basicnamevaluepair("gender", gender));                     params.add(new basicnamevaluepair("age", age));                     params.add(new basicnamevaluepair("phone", phone));                      log.d("entered values", params.tostring());                       jsonobject json = jsonparser.makehttprequest(url_create_user,"post", params);                       log.d("create response", json.tostring());                      try {                         int success = json.getint(tag_success);                          if (success == 1)                          {                              successvalue = tag_success;                             message = json.getstring("message");                           } else {                             // failed create product                             successvalue = "failere";                             message = json.getstring("message");                         }                     } catch (jsonexception e) {                         e.printstacktrace();                     }                      return null;                 }                 protected void onpostexecute(string file_url) {                     // dismiss dialog once product deleted                     pdialog.dismiss();                     if (successvalue.equals(tag_success)){                          toast.maketext(signup.this, "successfully created user", toast.length_long).show();                     }                     else {                         toast.maketext(signup.this, "some error in user creation", toast.length_long).show();                     }                 }                }         });      } } 

now signup url not working.
first make valid url , go url in web browser .
can test working url or not.
can see http://mysql14.000webhost.com/sign_up.php not available.

make new hosting account , upload files try .


Comments

Popular posts from this blog

Android : Making Listview full screen -

javascript - Parse JSON from the body of the POST -

javascript - Chrome Extension: Interacting with iframe embedded within popup -