¿No está insertando un registro en mysql con php-android?

I can get data from MySql with use of php using android successfully. But i m getting some problem with inserting record in mysql table using php-android.

This is my .php file:

 <?php
     mysql_connect("localhost","root","");
     mysql_select_db("database_name");
     $sql=mysql_query("insert into table_name values('".$_REQUEST['s_name']."')");
     $r=mysql_query($sql);
      if(!$r)echo "Error in query: ".mysql_error();mysql_close();
 ?>

This is my android activity's onCreate method's content.

    ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
    nameValuePairs.add(new BasicNameValuePair("s_name","StackOver"));

   try{ 
       HttpClient httpclient = new DefaultHttpClient();
       HttpPost httppost = new HttpPost("http://10.124.238.51PH/get_cities_names.php");
       httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
       HttpResponse response = httpclient.execute(httppost);
       HttpEntity entity = response.getEntity();
       is = entity.getContent();

     }catch(Exception e){
          Log.v("log_tag", "Error in http connection "+e);
     }

Here i want to pass BasicNameValuePair("s_name","StackOver")) s_name to .php but it can't be possibel. please give me some idea or links of tutorials. I have search in ner so much but i can't find proper tutorial for this. Thank you in advance.

preguntado el 28 de agosto de 12 a las 09:08

is 10.124.238.51PH a typo or just obfuscation? -

Accept some of your prev questions, just click the giant green ticks under the arrows. -

Thank you.... Lawrence Cherone to tell me the basic thing. -

1 Respuestas

Aquí está la tutoriales for saving data and passing data. Watch it, Learn from it and then create.

Respondido 28 ago 12, 10:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.