Salut à tous, lors de l'envoi des données à une base MySQL j'obtiens cette erreur : 
	
	08-16 10:30:40.466: E/JSON Parser(1267): Error parsing data org.json.JSONException: End of input at character 0 of
 Quelqu'un connait c'est dû à quoi ?
Mon Code JAVA : 
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 
 | / getting updated data from EditTexts
			String des = txtDes.getText().toString();
			String pri_uni = txtPriUni.getText().toString();
			String qte_dem= txtQteDem.getText().toString();
			String pri_tot = txtPriTot.getText().toString();
			Log.i("valeur",des);
 
			// Building Parameters
			List<NameValuePair> params = new ArrayList<NameValuePair>();
			//params.add(new BasicNameValuePair(TAG_PID, pid));
			params.add(new BasicNameValuePair(TAG_DES, des));
			params.add(new BasicNameValuePair(TAG_PRI_UNI, pri_uni));
			params.add(new BasicNameValuePair(TAG_QTE_DEM, qte_dem));
			params.add(new BasicNameValuePair(TAG_PRI_TOT, pri_tot));
			Log.i("NameValuePair",params.toString());
			// sending modified data through http request
			// Notice that update product url accepts POST method
			JSONObject json = jsonParser.makeHttpRequest(url_send_precommande,
					"POST", params);
 
			// check json success tag
			try {
				int success = json.getInt(TAG_SUCCESS);
				Log.i("resultat",String.valueOf(success));
				if (success == 1) {
					// successfully updated
					Intent i = getIntent();
					// send result code 100 to notify about product update
					setResult(100, i);
					finish();
				} else {
					// failed to update product
				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
 
			return null; | 
 Fichier PHP: 
	
	| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 
 | <?php
 
/*
 * Following code will update a product information
 * A product is identified by product id (pid)
 */
 
// array for JSON response
$response = array();
 
// check for required fields
 
//if (isset($_POST[pri_uni]) {
	if ( isset($_POST['des']) && isset($_POST['pri_uni']) && isset($_POST['qte_dem']) && isset($_POST['pri_tot']) ) {
 
    $des = $_POST['des'];
    $pri_uni = $_POST['pri_uni'];
    $qte_dem = $_POST['qte_dem'];
    $pri_tot = $_POST['pri_tot'];
 
 
    // include db connect class
    require_once __DIR__ . '/db_connect.php';
 
    // connecting to db
    $db = new DB_CONNECT();
 
    // mysql update row with matched pid
    $result = mysql_query("INSERT INTO 'precommande' ('des', 'pri_uni', 'qte_dem', 'pri_tot') VALUES ('$des', '$pri_uni', '$qte_dem', '$pri_tot')");
 
    // check if row inserted or not
    if ($result) {
        // successfully updated
        $response["success"] = 1;
        $response["message"] = "Précommande Envoyée";
 
        // echoing JSON response
        echo json_encode($response);
    } else {
 
    }
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Un ou plusieurs champs necessaire(s) manquant(s) !";
 
       echo json_encode($response);
}
?> | 
 
						
					
Partager