dovgqc2648 2016-01-03 07:44
浏览 51
已采纳

php中未定义的索引

Not sure what I have missed here. I give this error when workForce data get inserted. When I check MySQL, all data get inseted, only twf is 0.

enter image description here

   public void addWorkForce(final String subcontractors, final String noPeople, final String noHours, final long id)
    {
        class AddWorkForce extends AsyncTask<String, Void, String> {
            ProgressDialog loading;

            @Override
            protected void onPreExecute() {
                super.onPreExecute();
                loading = ProgressDialog.show(WorkDetailsTable.this, "Please Wait",null, true, true);
            }

            @Override
            protected void onPostExecute(String s) {
                super.onPostExecute(s);
                loading.dismiss();
                Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();
            }

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

                HashMap<String, String> data = new HashMap<String,String>();
                data.put(Config.KEY_SUBCONTRACTORS,subcontractors);
                data.put(Config.KEY_NUMBERPERSONS,noPeople);
                data.put(Config.KEY_NUMBERHOURS,noHours);
                data.put(Config.KEY_TWF,String.valueOf(id));
                RequestHandler rh=new RequestHandler();
                String result = rh.sendPostRequest(Config.ADD_WORKFORCE,data);
                return  result;
            }
        }

        AddWorkForce ru = new AddWorkForce();
        ru.execute(subcontractors,noPeople,noHours);
    }

addWorkForce.php

<?php 
    if($_SERVER['REQUEST_METHOD']=='POST'){

        //Getting values
        $subcontractors = $_POST['subcontractors'];
        $noPeople = $_POST['noPeople'];
        $noHours = $_POST['noHours'];
        $twf = $_POST['id'];


        //Creating an sql query
        $sql = "INSERT INTO work_force(subcontractors, number_of_person, number_of_hours, twf) VALUES ('$subcontractors','$noPeople','$noHours','$twf')";

        //Importing our db connection script
        require_once('dbConnect.php');

        //Executing query to database
        if(mysqli_query($con,$sql)){
            echo 'Work Force Added Successfully';
        }else{
            echo 'Could Not Add Work Force';
        }

        //Closing the database 
        mysqli_close($con);
    }
?>
  • 写回答

1条回答 默认 最新

  • dqc3469 2016-01-03 07:50
    关注

    check the name of this constant:

    Config.KEY_TWF
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器