android - Insert record to MySql from AndroidStudio only works when application Start -


i have application insert parameters in mysql table stored in hosting.

when start app first time , send information register succesfully added db. continue using application. if later try add registry, nothing happen, insert not realized. if close (kill) application , start again , send insert again works perfectly. in resume can send insert when first start app.

i checked debug , seems ok, if same log in both cases.

my android code following: public class asynccall extends asynctask {

this button call asynctask:

sentbutton.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             parametros.add(new basicnamevaluepair("categoria",intent.getstringextra("categoria")));             parametros.add(new basicnamevaluepair("titulo",intent.getstringextra("titulo")));             parametros.add(new basicnamevaluepair("latitud",double.tostring(latlng.latitude)));             parametros.add(new basicnamevaluepair("longitud",double.tostring(latlng.longitude)));             parametros.add(new basicnamevaluepair("cuerpo",descripcion.gettext().tostring()));             parametros.add(new basicnamevaluepair("user_id",string.valueof(user_id)));             parametros.add(new basicnamevaluepair("username",username));             parametros.add(new basicnamevaluepair("direccion",autocompleteubicacion.gettext().tostring()));             parametros.add(new basicnamevaluepair("tipo",tipo));             parametros.add(new basicnamevaluepair("fechainicio", strfechainicio));             parametros.add(new basicnamevaluepair("fechafin", strfechafin));              asynccall task=new asynccall();             task.execute();          }     }); 

and here doinbackground

    @override     protected void doinbackground(string... params) {          try {             httpclient httpclient = new defaulthttpclient();             httppost httppost = new httppost("http://xxxxx/insert.php");             httppost.setentity(new urlencodedformentity(parametros));             httpresponse response = httpclient.execute(httppost);          } catch (exception e) {             log.e("log_tag", "error in http connection " + e.tostring());         }          return null;     } 

my question: why insert works in first execution? checked , running , parameters ok in second execution, nothing inserted in db

my php file:

<?php      mysql_connect("localhost","xxxx","xxxx");     mysql_select_db("xxxxx");      $q=mysql_query("insert xxxx_table                (xxxx_category, xxxx_title, xxxx_description, xxxx_type,                 xxxx_location_lat, xxxx_location_lon, xxxx_direccion,                 username,id_user, xxxx_start_date,xxxx_end_date)          values ('".$_request['categoria']."','".$_request['titulo'].                 "','".$_request['cuerpo']."','".$_request['tipo'].                 "','".$_request['latitud']."','".$_request['longitud'].                 "','".$_request['direccion']."','".$_request['username'].                 "','".$_request['user_id']."','".$_request['fechainicio'].                 "','".$_request['fechafin']."')");      mysql_close();    ?> 

i found error, sending 1 of parameters in blank related table in bd.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -