title: Basic Android Interaction with MySQL database
body: <p>This is my first attempt at making an Android app interact with a MySQL database stored on a remote server. All I am trying to do at this point is to insert a single record into an empty remote table. Basically, I'm just trying to establish a connection and write very simple data.</p>
  
  <p>I'm not getting any errors, but my table is still empty after this runs. What am I doing wrong???</p>
  
  <p>/my_db/test.php
      
  
  <pre><code>    include('connection.php');
  
      $name='dummy';
  
      $sql = "INSERT INTO test (name) VALUES ('$name')";
      $result = mysql_query($sql);
  
      if(!$result) {return -1;}
  
      return 1;
  ?&gt;
  </code></pre>
  
  <p>This is in the onCreate function of my Activity:</p>
  
  <pre><code>btnRegister.setOnClickListener(new View.OnClickListener() {         
      public void onClick(View view) {
  
          //Avoiding threading issues for the moment
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy); 
  
          DefaultHttpClient httpclient = new DefaultHttpClient();
          String testURL = context.getResources().getString(R.string.dbURL) + "my_db/test.php";
          System.err.println(testURL); //output looks good 'http://XXX.XXX.XXX.XXX/my_db/test.php'
          HttpPost httppost = new HttpPost(testURL);
  
          try
          {
              //not actually using the passed parameter for now
              ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
              nameValuePairs.add(new BasicNameValuePair("name", inputFullName.getText().toString()));
  
              httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
              HttpResponse response = httpclient.execute(httppost);
              System.err.println("done");
          }
          catch(Exception e)
          {
              System.err.println("error");
              e.printStackTrace();
          }
      }
  });
  </code></pre>