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


im trying make user can change password after login. got error here. database dont want change after input new password. here code details. change password class:

public class password extends activity {  progressdialog pdialog; jsonarray jsona = new jsonarray(); jsonparser jsonparser = new jsonparser(); edittext password,enpassword,cpassword; button simpan; string spassword,success,id; static string email,npassword; textview tnama; sessionmanager session; private static string url = "http://10.0.2.2/login/editpass.php"; private static string url1 = "http://10.0.2.2/login/detail.php"; private static final string tag_id = "id";  //private static string url1 ="http://10.0.2.2/login/login.php"; @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_edit_pass);     session = new sessionmanager(getapplicationcontext());     toast.maketext(getapplicationcontext(),             "user login status: " + session.isloggedin(), toast.length_long)             .show();      session.checklogin();            hashmap<string, string> user = session.getuserdetails();      spassword = user.get(sessionmanager.tag_pass);     intent = getintent();     id = i.getstringextra(tag_id);     //textview tnama = (textview) findviewbyid(r.id.textnama);     //tnama.settext(semail);       password = (edittext) findviewbyid(r.id.password);     enpassword = (edittext)findviewbyid(r.id.npassword);     cpassword = (edittext)findviewbyid(r.id.cpassword);     simpan = (button) findviewbyid(r.id.simpan);     password.sethint(spassword);     list<namevaluepair> params = new arraylist<namevaluepair>();     params.add(new basicnamevaluepair("id",id));     //jsonobject json = jsonparser.makehttprequest(     //        url1, "get", params);     simpan.setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             if (enpassword.gettext().tostring().equals(cpassword.gettext().tostring())){                  // starting background task change password                   new resetpass().execute();             }else{                 toast.maketext(getapplicationcontext(), "password tidak cocok!!",                         toast.length_long).show();             }          }     }); }  public class resetpass extends asynctask<string, string, string> {       @override     protected void onpreexecute() {         super.onpreexecute();         pdialog = new progressdialog(password.this);         pdialog.setindeterminate(false);         pdialog.show();         pdialog.dismiss();     }      @override     protected string doinbackground(string... params) {         string newpass = enpassword.gettext().tostring();         list<namevaluepair> nvp = new arraylist<namevaluepair>();         nvp.add(new basicnamevaluepair(spassword, newpass));         hashmap<string, string> user = session.getuserdetails();         user.put(sessionmanager.tag_pass, newpass);         jsonobject json = jsonparser.makehttprequest(url, "post", nvp);         try {             success = json.getstring("success");          } catch (exception e) {             toast.maketext(getapplicationcontext(), "error",                     toast.length_long).show();         }          return null;     }      protected void onpostexecute(string file_url) {         // dismiss dialog once done         pdialog.dismiss();         if (success.equals("1")) {             toast.maketext(getapplicationcontext(), "password baru disimpan",                     toast.length_long).show();             intent a= new intent(password.this,myaccount.class);             startactivity(a);             finish();         } else {             toast.maketext(getapplicationcontext(), "gagal simpan password",                     toast.length_long).show();         }     }  } } 

php password :

<?php if (isset($_post['email'])&& isset($_post['password'])) {  $email = $_post['email']; $password=$_post['password']; $alamat=$_post['alamat']; $kodepos=$_post['kodepos']; $bank=$_post['bank']; $norek=$_post['norek']; include "koneksi.php";   $query = "update user set password = '$password' email = '$email'"; $hasil = mysql_query($query); mysql_query($query) or die(mysql_error()); if($hasil)     {     $response["success"] = "1";         $response["message"] = "data sukses diinput";         echo json_encode($response);     }     else     {$response["success"] = "0";      $response["message"] = "maaf , terjadi kesalahan";          // echoing json response         echo json_encode($response);     } } ?> 

json parser :

public class jsonparser {      static inputstream = null;     static jsonobject jobj = null;     static string json = "";      // constructor     public jsonparser() {      }      public jsonobject getjsonfromurl(string url) {          // making http request         try {             // defaulthttpclient             defaulthttpclient httpclient = new defaulthttpclient();             httppost httppost = new httppost(url);              httpresponse httpresponse = httpclient.execute(httppost);             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 {             jobj = new jsonobject(json);         } catch (jsonexception e) {             log.e("json parser", "error parsing data " + e.tostring());         }          // return json string         return jobj;      }      public jsonobject makehttprequest(string url, string method,             list<namevaluepair> params) {          // making http request         try {              // check request method             if (method == "post") {                 // request method post                 // defaulthttpclient                 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 {             jobj = new jsonobject(json);         } catch (jsonexception e) {             log.e("json parser", "error parsing data " + e.tostring());         }          // return json string         return jobj;      } } 

session manager :

@suppresslint("commitprefedits") public class sessionmanager {     // shared preferences     sharedpreferences pref;      // editor shared preferences     editor editor;      // context     context _context;      // shared pref mode     int private_mode = 0;      // nama sharepreference     private static final string pref_name = "sesi";      // shared preferences keys     private static final string is_login = "isloggedin";     public static final string key_name = "nama";     public static final string key_email = "email";     public static final string tag_kota="kota";     public static final string tag_nohp="nohp";     public static final string tag_pass="password";     public static final string tag_alamat="alamat";     public static final string tag_kodepos="kodepos";     public static final string tag_bank="bank";     public static final string tag_norek="norek";     //public static final string tag_noiden="noiden";     //public static final string tag_id="id";     // constructor     public sessionmanager(context context){         this._context = context;         pref = _context.getsharedpreferences(pref_name, private_mode);         editor = pref.edit();     }      /**      * create login session      * @param kota       * */     public void createloginsession(string name, string email, string kota, string nohp, string password, string alamat, string kodepos, string bank, string norek){         // storing login value true         editor.putboolean(is_login, true);         //editor.putint(tag_id, id);         editor.putstring(tag_pass, password);         editor.putstring(key_name, name);         editor.putstring(key_email, email);         editor.putstring(tag_kota, kota);         editor.putstring(tag_nohp, nohp);         editor.putstring(tag_alamat, alamat);         editor.putstring(tag_kodepos, kodepos);         editor.putstring(tag_bank, bank);         editor.putstring(tag_norek, norek);         editor.commit();     }         /**      * check login method wil check user login status      * if false redirect user login page      * else won't      * */     public void checklogin(){         // check login status         if(!this.isloggedin()){             intent = new intent(_context, mainactivity.class);             i.addflags(intent.flag_activity_clear_top);             i.setflags(intent.flag_activity_new_task);             _context.startactivity(i);             //((activity)_context).finish();         }      }        /**      * stored session data      * */     public hashmap<string, string> getuserdetails(){         hashmap<string, string> user = new hashmap<string, string>();         //user.put(tag_id, pref.getstring(tag_id,null));         user.put(key_name, pref.getstring(key_name, null));         user.put(key_email, pref.getstring(key_email, null));         user.put(tag_kota, pref.getstring(tag_kota, null));         user.put(tag_nohp, pref.getstring(tag_nohp, null));         user.put(tag_pass, pref.getstring(tag_pass, null));         user.put(tag_alamat, pref.getstring(tag_alamat, null));         user.put(tag_kodepos, pref.getstring(tag_kodepos, null));         user.put(tag_bank, pref.getstring(tag_bank, null));         user.put(tag_norek, pref.getstring(tag_norek, null));         return user;     }      /**      * clear session details      * */     public void logoutuser(){         // clearing data shared preferences         editor.clear();         editor.commit();          intent = new intent(_context, mainactivity.class);         i.addflags(intent.flag_activity_clear_top);         i.setflags(intent.flag_activity_new_task);         _context.startactivity(i);     }      public boolean isloggedin(){         return pref.getboolean(is_login, false);     } } 

and error :

05-29 23:24:20.011: i/choreographer(1065): skipped 53 frames!  application may doing work on main thread. 05-29 23:24:20.161: i/choreographer(1065): skipped 50 frames!  application may doing work on main thread. 05-29 23:24:22.701: i/choreographer(1065): skipped 194 frames!  application may doing work on main thread. 05-29 23:24:23.011: e/json parser(1065): error parsing data org.json.jsonexception: end of input @ character 0 of  05-29 23:24:23.371: i/choreographer(1065): skipped 253 frames!  application may doing work on main thread. 05-29 23:24:27.961: i/choreographer(1065): skipped 5355 frames!  application may doing work on main thread. 05-29 23:24:29.641: i/choreographer(1065): skipped 289 frames!  application may doing work on main thread. 05-29 23:24:30.521: i/choreographer(1065): skipped 301 frames!  application may doing work on main thread. 

i appreciate , answer pls me.thanks


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -