Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 为什么我的MySQL日期字段显示为;0000.00.00“;?_Php_Android_Mysql - Fatal编程技术网

Php 为什么我的MySQL日期字段显示为;0000.00.00“;?

Php 为什么我的MySQL日期字段显示为;0000.00.00“;?,php,android,mysql,Php,Android,Mysql,我创建了一个MySQL表“缺席”,其中包含列(id、StartDate、EndDate、Reason)。我用PHP在Android和MySQL之间建立了连接。一切都很好,只是在查看日期时,它仍然显示“0000.00.00”。当我使用phpMyAdmin访问我的数据库时,我看到了同样的问题 如何解决此问题?公共类活动{ private ProgressDialog pDialog; JSONParser jsonParser = new JSONParser(); EditText inputM

我创建了一个MySQL表“缺席”,其中包含列(id、StartDate、EndDate、Reason)。我用PHP在Android和MySQL之间建立了连接。一切都很好,只是在查看日期时,它仍然显示“0000.00.00”。当我使用phpMyAdmin访问我的数据库时,我看到了同样的问题


如何解决此问题?

公共类活动{

private ProgressDialog pDialog;

JSONParser jsonParser = new JSONParser();
EditText inputMatricule;
EditText inputDateDebut;
EditText inputDateFin;
EditText inputRaison;

// url to create new product
private static String url_Ajouter_Absence = "http://10.0.2.2/android_connect/AjouterAbsence.php";

// JSON Node names
private static final String TAG_SUCCESS = "success";


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_ajouter);

    // Edit Text
    inputMatricule = (EditText) findViewById(R.id.InputMatricule);
    inputDateDebut = (EditText) findViewById(R.id.InputDateDebut);
    inputDateFin = (EditText) findViewById(R.id.InputDateFin);
    inputRaison = (EditText) findViewById(R.id.InputRaison);

    // Create button
    Button btnAjouterAbsence = (Button) findViewById(R.id.btnAjouterAbsence);

    // button click event
    btnAjouterAbsence.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            // creating new product in background thread
            new CreateNewProduct().execute();
        }
    });
}

/**
 * Background Async Task to Create new product
 * */
class CreateNewProduct extends AsyncTask<String, String, String> {

    /**
     * Before starting background thread Show Progress Dialog
     * */
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(Ajouter.this);
        pDialog.setMessage("Creating Product..");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(true);
        pDialog.show();
    }

    /**
     * Creating product
     * */
    protected String doInBackground(String... args) {
        String Matricule = inputMatricule.getText().toString();
        String DateDebut = inputDateDebut.getText().toString();
        String DateFin = inputDateFin.getText().toString();
        String Raison = inputRaison.getText().toString();

        // Building Parameters
        List<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("Matricule", Matricule));
        params.add(new BasicNameValuePair("DateDebut", DateDebut));
        params.add(new BasicNameValuePair("DateFin", DateFin));
        params.add(new BasicNameValuePair("Raison", Raison));

        // getting JSON Object
        // Note that create product url accepts POST method
        JSONObject json = jsonParser.makeHttpRequest(url_Ajouter_Absence,
                "POST", params);

        // check log cat from response
        Log.d("Create Response", json.toString());

        // check for success tag
        try {
            int success = json.getInt(TAG_SUCCESS);

            if (success == 1) {
                // successfully created product
                Intent i = new Intent(getApplicationContext(), Consulter.class);
                startActivity(i);

                // closing this screen
                finish();
            } else {
                // failed to create product
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

        return null;
    }

    /**
     * After completing background task Dismiss the progress dialog
     * **/
    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();
    }

}
private ProgressDialog pDialog;
JSONParser JSONParser=新的JSONParser();
编辑文本输入矩阵;
编辑文本输入日期;
编辑文本输入日期;
编辑文本输入;
//创建新产品的url
私有静态字符串url\u Ajouter\u缺失=”http://10.0.2.2/android_connect/AjouterAbsence.php";
//JSON节点名称
私有静态最终字符串标记_SUCCESS=“SUCCESS”;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_-ajouter);
//编辑文本
InputMatrix=(EditText)findViewById(R.id.InputMatrix);
InputDateFirst=(EditText)findViewById(R.id.InputDateFirst);
inputDateFin=(EditText)findViewById(R.id.inputDateFin);
inputRaison=(EditText)findViewById(R.id.inputRaison);
//创建按钮
按钮BtnaJouerAbsence=(按钮)findViewById(R.id.BtnaJouerAbsence);
//按钮点击事件
btnajouerAbsence.setOnClickListener(新视图.OnClickListener()){
@凌驾
公共void onClick(视图){
//在后台线程中创建新产品
新建CreateNewProduct().execute();
}
});
}
/**
*创建新产品的后台异步任务
* */
类CreateNewProduct扩展了AsyncTask{
/**
*在启动后台线程显示进度对话框之前
* */
@凌驾
受保护的void onPreExecute(){
super.onPreExecute();
pDialog=newprogressdialog(ajour.this);
pDialog.setMessage(“创建产品…”);
pDialog.setUndeterminate(假);
pDialog.setCancelable(真);
pDialog.show();
}
/**
*创造产品
* */
受保护的字符串doInBackground(字符串…args){
String Matricule=inputMatricule.getText().toString();
字符串DateDefinith=InputDateDefinith.getText().toString();
字符串DateFin=inputDateFin.getText().toString();
String Raison=inputRaison.getText().toString();
//建筑参数
List params=new ArrayList();
参数添加(新的BasicNameValuePair(“矩阵”,矩阵));
参数添加(新的BasicNameValuePair(“Date处女秀”,Date处女秀));
添加(新的BasicNameValuePair(“DateFin”,DateFin));
参数add(新的BasicNameValuePair(“Raison”,Raison));
//获取JSON对象
//请注意,创建产品url接受POST方法
JSONObject json=jsonParser.makeHttpRequest(url\u Ajouter\u),
“POST”,params);
//从响应中检查日志cat
d(“创建响应”,json.toString());
//检查成功标签
试一试{
int success=json.getInt(TAG_success);
如果(成功==1){
//已成功创建产品
Intent i=新的Intent(getApplicationContext(),consutter.class);
星触觉(i);
//关闭此屏幕
完成();
}否则{
//未能创建产品
}
}捕获(JSONException e){
e、 printStackTrace();
}
返回null;
}
/**
*完成后台任务后,关闭“进度”对话框
* **/
受保护的void onPostExecute(字符串文件\u url){
//完成后关闭对话框
pDialog.disclose();
}
}

}

我打赌这就是插入的值(转换后)。我如何更正它?当您将数据保存到数据库时,它是否为日期保存了正确的数据?数据库中endDate和startDate的数据类型是什么?数据类型是date