php - data not save to mySQL Hosted DB -


i want save data android app mysql database in server. make code php.. when run php file data saved db.. run form android application. data not save db.

save code in android

 public void loadsave() {               string mydataurl = "http://xxxxxxxxxx/savedata.php";           //string type = params[0];          try {          string longi = "aaa"; // double.tostring(location.getlongitude());         string lati = "aare";//double.tostring(location.getlatitude());         string user = "a";         string lisence = "b";         string date = "c";         url url = new url(mydataurl);         httpurlconnection httpurlconnection = (httpurlconnection) url.openconnection();         httpurlconnection.setrequestmethod("post");         httpurlconnection.setdooutput(true);         httpurlconnection.setdoinput(true);         outputstream outputstream = httpurlconnection.getoutputstream();         bufferedwriter bufferedwriter = new bufferedwriter(new outputstreamwriter(outputstream, "utf-8"));         string post_data = urlencoder.encode("longi", "utf-8") + "=" + urlencoder.encode(longi, "utf-8") + "&" +                 urlencoder.encode("lati", "utf-8") + "=" + urlencoder.encode(lati, "utf-8") + "&" +                 urlencoder.encode("user", "utf-8") + "=" + urlencoder.encode(user, "utf-8") + "&" +                 urlencoder.encode("lisence", "utf-8") + "=" + urlencoder.encode(lisence, "utf-8") + "&" +                 urlencoder.encode("date", "utf-8") + "=" + urlencoder.encode(date, "utf-8");         bufferedwriter.write(mydataurl);         bufferedwriter.flush();         bufferedwriter.close();         outputstream.close();                 } catch (malformedinputexception e) {         e.printstacktrace();     } catch (ioexception ex) {         ex.printstacktrace();     }  } 

php code

require "db_connection.php";  $longi =$_post["longi"]; $lati = $_post["lati"]; $user = $_post["user"]; $lisence =$_post["lisence"]; $date = $_post["date"];  $query1="insert mapdata (longi,lati,user,lisence,date)    values ('".$longi."','".$lati."','".$user."','".$lisence."', '".$date."' )";  mysql_query($query1) or die ('error :' . mysql_error()); 

calling loadsave()

    new asynctask<void, void, void>() {          @override         protected void doinbackground(final void... params) {             loadsave();             return null;         }     }.execute(); 


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -