How to Insert Data to Mysql Database using Volley
<p>I am trying to insert data to mysql database using volley, but it always response as error, I'm stuck and cant go further to my project. I can't find what causing it not to execute the my PHP codes. I also checked my PHP code using PostMan and it is working well. I'm now trying to insert some test data to it but still no luck. I hope you can shine some light in me and provide me some help. Thank you.</p>

<p>Insert.Java</p>

<pre><code>Button confirmOrder = (Button) findViewById(R.id.confirmOrder);
        confirmOrder.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                final int a = 1;
                final String b = "Beth";
                final int c = 1;
                final int d = 3;
                final int e = 1;
                final String f = "Bert";



                final String URL = "https://10.0.2.2/myDB/order.php";

                StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener&lt;String&gt;() {
                    @Override
                    public void onResponse(String response) {
                        if(response.contains("success")) {
                            Toast.makeText(getApplicationContext(), "success", Toast.LENGTH_SHORT).show();
                        }
                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(getApplicationContext(),"failed",Toast.LENGTH_SHORT).show();
                    }
                }){
                    @Override
                    protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                        Map&lt;String, String&gt; params = new HashMap&lt;&gt;();
                        params.put("table_id", String.valueOf(a));
                        params.put("cust_name", b);
                        params.put("item_id", String.valueOf(c));
                        params.put("quantity", String.valueOf(d));
                        params.put("status_id", String.valueOf(e));
                        params.put("username", f);
                        return params;
                    }
                };

                MySingleton.getInstance(getApplicationContext()).addToRequestQueue(stringRequest);

            }
        });
</code></pre>

<p>order.php</p>

<pre><code>&lt;?php
include_once("init.php");

if(isset($_POST['table_id']) &amp;&amp; isset($_POST['cust_name']) &amp;&amp; 
   isset($_POST['item_id']) &amp;&amp; isset($_POST['quantity']) &amp;&amp; isset($_POST['status_id'])
   &amp;&amp; isset($_POST['username'])){
       $tableid = $_POST['table_id'];
       $custname = $_POST['cust_name'];
       $itemid = $_POST['item_id'];
       $quantity = $_POST['quantity'];
       $statusid = $_POST['status_id'];
       $username = $_POST['username'];

       $query = "INSERT INTO tbl_order(table_id,cust_name,item_id,quantity,status_id,username)
       VALUES ('$tableid', '$custname', '$itemid', '$quantity', '$statusid', '$username')";

     $result = mysqli_query($con, $query);

    if($result &gt; 0){
        echo "success";   
    }
    else{
        echo "failed";   
    }
}


?&gt;
</code></pre>