My Android app is not getting any response from server

I’m a beginner in Android. Actually I’m trying to receive data from server and check that the entered username and password is correct or not, but it’s not getting any response event showing “Wrong Match”. I also checked the JSON output it is suppose to show success if entered “Hello” as name and “Hi” as password but it’s not showing anything on button click. I’ve also added Internet permission in Manifest.xml.

MainActivity.java

public class MainActivity extends AppCompatActivity {
 private static final String REGISTER_URL = "http://192.168.43.218/define_testing.php";
 EditText username,pass;
 Button login;
 @Override
 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    login = (Button) findViewById(R.id.login);
    username=(EditText)findViewById(R.id.username);
    pass=(EditText)findViewById(R.id.password);
    login.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                 StringRequest request=new StringRequest(REGISTER_URL, new Response.Listener<String>() {
                        @Override
                        public void onResponse(String response) {
                            try {
                                JSONObject jsO= new JSONObject(response);

                                JSONArray array = null;

                                array = jsO.getJSONArray("result");

                                    JSONObject obj = array.getJSONObject(0);
                                    String name= obj.getString("name");
                                    String password=obj.getString("password");

                                    String enterName=username.getText().toString();
                                    String enterPass=pass.getText().toString();
                                    if(name.equals(enterName) && password.equals(enterPass)){
                                        Toast.makeText(getApplicationContext(),"Success",Toast.LENGTH_SHORT).show();
                                    }
                                    else {
                                        Toast.makeText(getApplicationContext(),"Wrong Match",Toast.LENGTH_SHORT).show();
                                    }



                            }
                            catch (JSONException e1) {
                                e1.printStackTrace();
                            }
                        }},new Response.ErrorListener() {
                        @Override
                        public void onErrorResponse(VolleyError error) {
                            Toast.makeText(getApplicationContext(),"Internet Problem",Toast.LENGTH_SHORT).show();
                        }
                    });
                    RequestQueue requestQueue= Volley.newRequestQueue(getApplicationContext());
                    requestQueue.add(request);
                }
            }
    );


   }

 }

PHP script

<?php
 require ('connection.php');

  $name  = 'Hello';

 $sql = "SELECT * FROM new_one_user_information WHERE username='".$name."'";

 $r = mysqli_query($connect,$sql);

 $res = mysqli_fetch_array($r);

$result = array();

array_push($result,array(
"name"=>$res['username'],
"password"=>$res['password']
      )
     );

echo json_encode(array("result"=>$result));


 mysqli_close($connect);
 ?>

Output of this PHP script is:

Connection Established
{"result":[{"name":"Hello","password":"Hi"}]}

Error in logcat:

org.json.JSONException: Value Connection of type java.lang.String cannot be converted to JSONObject
  at org.json.JSON.typeMismatch(JSON.java:111)
  at org.json.JSONObject.<init>(JSONObject.java:159)
  at org.json.JSONObject.<init>(JSONObject.java:172)
  at com.example.srinu.stackview2.MainActivity.checkIt(MainActivity.java:85)
  at com.example.srinu.stackview2.MainActivity$1$1.onResponse(MainActivity.java:68)
  at com.example.srinu.stackview2.MainActivity$1$1.onResponse(MainActivity.java:50)
  at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:67)
  at com.android.volley.toolbox.StringRequest.deliverResponse(StringRequest.java:30)
  at com.android.volley.ExecutorDelivery$ResponseDeliveryRunnable.run(ExecutorDelivery.java:99)
  at android.os.Handler.handleCallback(Handler.java:733)
  at android.os.Handler.dispatchMessage(Handler.java:95)
  at android.os.Looper.loop(Looper.java:136)
  at android.app.ActivityThread.main(ActivityThread.java:5001)
  at java.lang.reflect.Method.invokeNative(Native Method)
  at java.lang.reflect.Method.invoke(Method.java:515)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
  at dalvik.system.NativeStart.main(Native Method)

There must be a “Connection Established” message inside the required connection.php file.

And that’s the reason why the php response is not a valid json.