0

OUTPUT ----> Hosting 24 Analytic code

This code am using on php side to update my database values. when check on search box it work fine and send nice response like when give correct values it gives 1 else give 0 but on android side i'am not able to get response

<?php
    $con = mysql_connect("mysql6.000webhost.com","a2963262_rock","ahsan7816217");
    mysql_select_db("a2963262_Project",$con);

    $job_id = $_REQUEST['jobId'];
    $status = $_REQUEST['status'];

    $flag['code']="0";

    $query = mysql_query("select * from Job where job_Id='$job_id' ");
    $result = mysql_num_rows($query);

    if($result>0)
    {
        mysql_query("UPDATE Job SET job_status='$status' WHERE job_Id='$job_id' ");
        $flag['code']="1";
    }
    echo $flag['code'];

    mysql_close($con);
?>

I am using this code on android side to connect with php web service to update my database column. When execute this code It work fine on database side and values goes into database but when getting response it show some illegal code or text.

 private class UpdateStatus extends AsyncTask<String,Void,String> {
    ProgressDialog dialog = new ProgressDialog(MainActivity.this);

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        dialog.setMessage("Plz Wait....");
        dialog.show();
    }

    String text = "";
    ArrayList<String> list;

    @Override
    protected String doInBackground(String... urls) {

        for (String url1 : urls) {
            try {
                //add your data
                ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
                // Always use the same variable name for posting i.e the android side variable name and php side variable name should be similar,
                nameValuePairs.add(new BasicNameValuePair("jobId", id.getText().toString()));
                nameValuePairs.add(new BasicNameValuePair("status", status.getText().toString()));

                HttpClient httpclient = new DefaultHttpClient();
                HttpPost httppost = new HttpPost(url1);
                httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
                //Execute HTTP Post Request
                HttpResponse response = httpclient.execute(httppost);

                HttpEntity entity = response.getEntity();
                inputStream = entity.getContent();
            } catch (IOException e) {
                Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_LONG).show();
            }

            BufferedReader reader;
            try {
                reader = new BufferedReader(new InputStreamReader(inputStream));
                StringBuilder sb = new StringBuilder();
                String line = null;

                // Read Server Response
                while ((line = reader.readLine()) != null) {
                line = reader.readLine();
                sb.append(line);
                break;
                }
                text = sb.toString();
            } catch (IOException e) {

                e.printStackTrace();
            }

        }
        return text;
    }

    @Override
    protected void onPostExecute(String result) {

            Toast.makeText(MainActivity.this,result,Toast.LENGTH_LONG).show();

        dialog.dismiss();
    }
}
kandroidj
  • 13,784
  • 5
  • 64
  • 76

0 Answers0