dpw50696 2015-05-03 15:06
浏览 113

Android:数据库表不会更新

In my app I have an EditText where the user can add his personal info. When he is done writing, he clicks a button and the corresponding DB column is supposed to be updated, but is not.

Here is my php script :

<?php
$con = mysqli_connect('127.0.0.1','root','lokijuhy1');
mysqli_select_db($con,'twentythree');
$response = array();

if(isset($_POST['about_me']) && isset($_POST['name']) && isset($_POST['uid'])){

    $about_me = $_POST['about_me'];
    $name = $_POST['name'];
    $uid = $_POST['uid'];

    $query = "UPDATE profile SET about_me = $about_me WHERE unique_id = $uid";
    $result = mysqli_query($con,$query);
    if ($result){

       $response["success"] = 1;
       $response["message"] = "Success";
       echo json_encode($response);
    } else {
       $response["success"] = 0;
       $response["message"] = "Table was not Updated";
       echo json_encode($response);
    }

}else {
   $response["success"] = 0;
   $response["message"] = "Something is missing!";
   echo json_encode($response);


}

?>

And here is my Java code :

class  updateProfile extends AsyncTask<String, String, String> {


        @Override
        protected void onPreExecute() {
            super.onPreExecute();

        }

        protected String doInBackground(String... args) {


            // Building Parameters
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            params.add(new BasicNameValuePair("name",name));
            params.add(new BasicNameValuePair("uid",uid));

            params.add(new BasicNameValuePair("about_me", about_me));
            JSONParser jsonParser = new JSONParser();
            JSONObject json = jsonParser.makeHttpRequest(Config.URL_profileUpdate,
                    "POST", params);

            try {
            // Checking for SUCCESS TAG

            int success = json.getInt("success");
            String message = json.optString("message");
            if (success == 1) {
                System.out.println(message);
            }

        }catch (JSONException e) {
            e.printStackTrace();
        }  

            return null;



        protected void onPostExecute(String file_url) {


        }

Do you guys have any idea why this happens?

Note : I just noticed that I get a positive JSON response, but the response message is null.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥100 set_link_state
    • ¥15 虚幻5 UE美术毛发渲染
    • ¥15 CVRP 图论 物流运输优化
    • ¥15 Tableau online 嵌入ppt失败
    • ¥100 支付宝网页转账系统不识别账号
    • ¥15 基于单片机的靶位控制系统
    • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
    • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
    • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
    • ¥15 手机接入宽带网线,如何释放宽带全部速度