BhargavSushant BhargavSushant - 10 months ago 54
Android Question

Code not sending data over Volley to mysql

I am trying to update mysql database using volley post method, even though php is successfully being called yet database is not getting sent values. My php updates table with sent values and a unique id that is genereated by php , php successfully fires query and updates the id column but not the data column that was sent from android.

Following is the java code

package com.attosectechnolabs.cardviewone;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;


import java.util.HashMap;
import java.util.Map;

public class forum extends AppCompatActivity {

String thread_text, User = "Test";
Context ctx;
EditText new_thread_text;
TextView resulttemp;
Button submit_thread, cancel_thread;
private static final String REGISTER_URL = "";
public static final String KEY_THREAD = "thread";
public static final String KEY_USERNAME = "User";

public forum() {

protected void onCreate(Bundle savedInstanceState) {
Intent intent = getIntent();

submit_thread = (Button) findViewById(;
cancel_thread = (Button) findViewById(;
new_thread_text = (EditText) findViewById(;
resulttemp = (TextView) findViewById(;

submit_thread.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {



private void insertThreadText() {

final String thread_text = new_thread_text.getText().toString().trim();

StringRequest stringRequest = new StringRequest(Request.Method.POST, REGISTER_URL,
new Response.Listener<String>() {
public void onResponse(String response) {
Toast.makeText(forum.this, response, Toast.LENGTH_LONG).show();
new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
Toast.makeText(forum.this, error.toString(), Toast.LENGTH_LONG).show();
}) {
protected Map<String, String> getParams() {
Map<String, String> params = new HashMap<String, String>();
params.put(KEY_THREAD, thread_text);
params.put(KEY_USERNAME, User);
return params;

RequestQueue requestQueue = Volley.newRequestQueue(this);

it seems I am messing up the post request but I don't know what it is.


Sorry guys it was a silly mistake, instead of

public static final String KEY_THREAD = "thread";

it should have been

public static final String KEY_THREAD = "thread_text";

thank you for your time.