Android error when trying to connect to database using php
<p>Hi Guys i am trying to get city names from datbase using android php and mysql but code is not working,here is my code</p>

<p>pleas help me</p>

<p>this is the server side code</p>

<pre><code>PHP SERVER CODE

&lt;?php
mysql_connect("HOST","USER","PASSWORD");
mysql_select_db("DATABASE");
$sql=mysql_query("select * from CITY");
while($row=mysql_fetch_assoc($sql))
$output[]=$row;
print(json_encode($output));
mysql_close();
?&gt;
here i am trying to fetch the mysql table results





 ANDROID CODE


            try{
                  JSONArray jArray = new JSONArray(result);
                  JSONObject json_data=null;
                  for(int i=0;i&lt;jArray.length();i++){
                         json_data = jArray.getJSONObject(i);
                         ct_id=json_data.getInt("CITY_ID");
                         ct_name=json_data.getString("CITY_NAME");
                     }
                  }
                  catch(JSONException e1){
                      Toast.makeText(getBaseContext(), "No City Found" ,Toast.LENGTH_LONG).show();
                  } catch (ParseException e1) {
                        e1.printStackTrace();
                }
</code></pre>
