title: Sending two json_encode array from php to android
body: <p>I am trying to send two arrays from PHP to android, but I am getting a json error in android "json error: no value for visited"</p>
  
  <p>Below is my PHP</p>
  
  <pre><code>function mylogin($data){ 
      $db = new DB_Functions(); global $response;
      if (isset($data['email']) &amp;&amp; isset($data['password'])) {
        $email = $data['email'];
        $password = $data['password'];
        $user = $db-&gt;getUserByEmailAndPassword($email, $password);
        if ($user != false) { 
           $response["userError"] = FALSE;
           $response["uid"] = $user["unique_id"];
           $response["user"]["name"] = $user["name"];
           $response["user"]["email"] = $user["email"];
           $response["user"]["created_at"] = $user["created_at"];
           $response["user"]["updated_at"] = $user["updated_at"];
           echo json_encode($response);
           echo jp();
         } else {
            $response["error"] = TRUE;
            $response["error_msg"] = "Login credentials are wrong. Please try again!";
            echo json_encode($response); 
            }
        }
   }
  
  function jp(){ 
      $filename = "visited.xml";
      $eachRowValue = array("error" =&gt; FALSE);
      $visited = array();
      $jsonData = array();
      $eachCellValue = array();
      $jsonTempData  = array();
      $output = "";
      if (file_exists($filename))
      {
          global $eachRowValue;
          $dom = new DOMDocument(); 
          $dom-&gt;load($filename);
          $rows = $dom-&gt;getElementsByTagName( 'Row' );
          $counter = 0;
          foreach ($rows as $row)
          {
              $i = 0;
              $cells = $row-&gt;getElementsByTagName( 'Cell' );
                  foreach( $cells as $cell )
                  { 
                      $eachCellValue[$i] = $cell-&gt;nodeValue;
                      $i++;
                  }
                  $jsonTempData['oid']=$eachCellValue[2];
                  $jsonTempData['name']= $eachCellValue[3];
                  $jsonTempData['geox']=$eachCellValue[4];
                  $jsonTempData['geoy']=$eachCellValue[5];
                  $jsonData[$counter]=json_encode($jsonTempData);
                  $counter++;
  
          }
          $visited['visited']=$jsonData;
          return json_encode($visited);
      }
      else {
          return 0; }
  }
  </code></pre>
  
  <p>Below is my android java code  </p>
  
  <pre><code>private void checkLogin(final String email, final String password) {
      // Tag used to cancel the request
      String tag_string_req = "req_login";
  
      pDialog.setMessage("Logging in ...");
      showDialog();
  
      StringRequest strReq = new StringRequest(Method.POST,
              AppConfig.URL_LOGIN, new Response.Listener&lt;String&gt;() {
  
          @Override
          public void onResponse(String response) {
              Log.d(TAG, "Login Response: " + response.toString());
  
              try {
                  JSONObject jObj = new JSONObject(response);
  
  
                  boolean userError = jObj.getBoolean("userError");
                  // Check for error node in json
                  if ( !userError)  {
  
                      session.setLogin(true);
  
                      // Now store the user in SQLite
                      String uid = jObj.getString("uid");
                      JSONObject user = jObj.getJSONObject("user");
                      String name = user.getString("name");
                      String email = user.getString("email");
                      String created_at = user.getString("created_at");
                      db.addUser(name, email, uid, created_at);
                      Toast.makeText(getApplicationContext(), "Login Successful ", Toast.LENGTH_LONG).show();
  
                      pDialog.setMessage("Download data ...");
                      JSONObject jObjj = new JSONObject(response);
                      JSONArray visited = jObjj.getJSONArray("visited");
                      Toast.makeText(getApplicationContext(), "Downloading Journey Plan ", Toast.LENGTH_LONG).show();
                      for (int i = 0; i &lt; visited.length(); i++)
                      {
                          JSONObject jdata=visited.getJSONObject(i);
                          Integer oid = jdata.getInt("oid");
                          String oname = jdata.getString("name");
                          Double geox = jdata.getDouble("geox");
                          Double geoy = jdata.getDouble("geoy");
                          db.addVisited(oid, oname, geox,geoy);
                      }
  
                      // Launch main activity
                      Intent intent = new Intent(LoginActivity.this,
                              MainActivity.class);
                      startActivity(intent);
                      finish();
                  } else {
                      // Error in login. Get the error message
                      String errorMsg = jObj.getString("error_msg");
                      Toast.makeText(getApplicationContext(),
                              errorMsg, Toast.LENGTH_LONG).show();
                  }
              } catch (JSONException e) {
                  // JSON error
                  e.printStackTrace();
                  Toast.makeText(getApplicationContext(), "Json error: " + e.getMessage(), Toast.LENGTH_LONG).show();
              }
  
          }
      }, new Response.ErrorListener() {
  
          @Override
          public void onErrorResponse(VolleyError error) {
              Log.e(TAG, "Login Error: " + error.getMessage());
              Toast.makeText(getApplicationContext(),
                      error.getMessage(), Toast.LENGTH_LONG).show();
              hideDialog();
          }
      }) {
  
          @Override
          protected Map&lt;String, String&gt; getParams() {
              // Posting parameters to login url
              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("email", email);
              params.put("password", password);
              params.put("frmtype", "login");
              return params;
          }
  
      };
  
      // Adding request to request queue
      AppController.getInstance().addToRequestQueue(strReq, tag_string_req);
  }
  </code></pre>
  
  <p>As you can see I am trying to login a user and once the user is authenticated, I am downloading his visited places. When I run the above code, user is authenticated but I am not getting his visited places. I am getting json error "no value for visit"</p>