android app wrote to get place name of id 2 php gives null
<p>I was trying out this code but it gives null. where it should be giving me the place name. what seems to be the problem in my code? i want to get place details by giving the place ID. But i debugged too, it was always returning null </p>

<p><strong>Code</strong>            </p>

<pre><code>String result = "";
                InputStream is = null;
                // the year data to send
                ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                nameValuePairs.add(new BasicNameValuePair("place_id", "2"));

                // http post
                try {
                    HttpClient httpclient = new DefaultHttpClient();
                    HttpPost httppost = new HttpPost(
                            "http://example.com/getAllPeopleBornAfter.php");
                    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                    HttpResponse response = httpclient.execute(httppost);
                    HttpEntity entity = response.getEntity();
                    is = entity.getContent();
                } catch (Exception e) {
                    Log.e("log_tag", "Error in http connection " + e.toString());
                }
                // convert response to string
                try {
                    BufferedReader reader = new BufferedReader(
                            new InputStreamReader(is, "iso-8859-1"), 8);
                    StringBuilder sb = new StringBuilder();
                    String line = null;
                    while ((line = reader.readLine()) != null) {
                        sb.append(line + "\n");
                    }
                    is.close();

                    result = sb.toString();
                } catch (Exception e) {
                    Log.e("log_tag", "Error converting result " + e.toString());
                }

                // parse json data
                try {
                    JSONArray jArray = new JSONArray(result);
                    for (int i = 0; i &lt; jArray.length(); i++) {
                        JSONObject json_data = jArray.getJSONObject(i);
                        TextView z = (TextView)findViewById(R.id.textView1);
                        z.setText(json_data.getString("place_id"));
                    }
                } catch (JSONException e) {
                    Log.e("log_tag", "Error parsing data " + e.toString());
                }
            }

        });
</code></pre>

<p><strong>PHP</strong></p>

<pre><code>&lt;?php
include "db_config.php";

$q=mysql_query("SELECT 'name' FROM places WHERE place_id='".$_REQUEST['place_id']."'");

while($e=mysql_fetch_assoc($q))
        $output[]=$e;

print(json_encode($output));

mysql_close();
?&gt;
</code></pre>
