title: Can't find the JSON parsing error that the logcat is complaining about
body: <p>I'm was trying a tutorial to get data to android from a MySQL database that you can find here:
  <a href="http://www.helloandroid.com/tutorials/connecting-mysql-database" rel="nofollow">http://www.helloandroid.com/tutorials/connecting-mysql-database</a></p>
  
  <p>So this is the table from where I'm trying to fetch data:</p>
  
  <pre><code>CREATE  TABLE IF NOT EXISTS `pfc_db`.`capas` (
    `id` VARCHAR(10) NOT NULL ,
    `nombre` VARCHAR(50) NOT NULL ,
    PRIMARY KEY (`id`) )
  ENGINE = InnoDB;
  </code></pre>
  
  <p>This is the fragment of the php script where the query is performed:</p>
  
  <pre><code>$query = "select * from CAPAS";
  
  $sql=mysql_query($query);
  if (!$sql) {
      die("The query ($query) could not be executed in the BD: " . mysql_error());
  }
  while( $row=mysql_fetch_array($sql)){
      $output[]=$row;
      if (isset($output)){
          echo "yes ";
              echo $output[0]['nombre'];
      }
      else{echo "no";}
  }
  print(json_encode($output));
  mysql_close();
  </code></pre>
  
  <p>It works perfectly on the browser.
  This is the android code:</p>
  
  <pre><code>package com.example.androidconn;
  
  import java.io.BufferedReader;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.util.Log;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  
  public class AndroidConnection extends Activity {
      /** Called when the activity is first created. */
      TextView txt;
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          // Create a crude view - this should really be set via the layout resources  
          // but since its an example saves declaring them in the XML.  
          LinearLayout rootLayout = new LinearLayout(getApplicationContext());  
          txt = new TextView(getApplicationContext());  
          rootLayout.addView(txt);  
          setContentView(rootLayout);  
  
          // Set the text and call the connect function.  
          txt.setText("Connecting..."); 
          //call the method to run the data retreival
          txt.setText(getServerData(KEY_121)); 
      }
  
      public static final String KEY_121 = "http://10.0.2.2/api/prueba.php"; //i use my real ip here
  
      private String getServerData(String returnString) {
  
          InputStream is = null;
  
          String result = "";
          //the year data to send
          ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
          nameValuePairs.add(new BasicNameValuePair("nombre","Escuelas"));
  
          //http post
          try{
                  HttpClient httpclient = new DefaultHttpClient();
                  HttpPost httppost = new HttpPost(KEY_121);
                  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);
                          Log.i("log_tag","id: "+json_data.getString("id")+
                                  ", nombre: "+json_data.getString("nombre")
                          );
                          //Get an output to the screen
                          returnString += "\n\t" + jArray.getJSONObject(i); 
                  }
          }catch(JSONException e){
                  Log.e("log_tag", "Error parsing data "+e.toString());
          }
          return returnString; 
      }    
  }
  </code></pre>
  
  <p>And finally this is the logcat:</p>
  
  <pre><code>D/AndroidRuntime(  313): &gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; AndroidRuntime START &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  D/AndroidRuntime(  313): CheckJNI is ON
  D/AndroidRuntime(  313): --- registering native functions ---
  I/ActivityManager(   58): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.androidconn/.AndroidConnection }
  D/AndroidRuntime(  313): Shutting down VM
  D/dalvikvm(  313): Debugger has detached; object registry had 1 entries
  I/AndroidRuntime(  313): NOTE: attach of thread 'Binder Thread #3' failed
  E/log_tag (  281): Error parsing data org.json.JSONException: Value yes of type java.lang.String cannot be converted to JSONArray
  I/ActivityManager(   58): Displayed activity com.example.androidconn/.AndroidConnection: 1636 ms (total 1636 ms)
  </code></pre>
  
  <p>I've been reading the comments on the tutorial so that maybe someone had the same error but I didn't find it, which is a bit weird.</p>
  
  <p>I checked similar posts here, but they didn't help. If this question is repeated please point me to the answer, and if it's not, any help would be appreciated!</p>