I have an application that insert certain parameters in a MySQL table stored in a hosting.
When i start the app for first time and send the information the register is succesfully added to the DB. Then i continue using the application. If later i try to add another registry, nothing happen, the insert is not realized. If i close (kill) the application and start it again and send the insert again it works perfectly. So in resume i can only send the insert when i first start the app.
I checked the debug and seems to be ok, if the same log in both cases.
My Android code is the following: public class AsyncCall extends AsyncTask {
This is the button that call the 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 is the 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 the insert only works in the first execution? I checked and its running and the parameters are ok in the second execution, but nothing is inserted in the DB
My PHP file:
<?php
    mysql_connect("localhost","xxxx","xxxx");
    mysql_select_db("xxxxx");
    $q=mysql_query("INSERT INTO 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();
   ?>
 
    