0

php-mysqlとjsonを使用してこのエラーが発生しています。真剣に2日間費やしたので、ここに私のコードがあります

require "includes/connexion.php";
$requete="SELECT * FROM contacts;";
$rep=$pdo->query($requete);

while($data=$rep->fetch(PDO::FETCH_ASSOC)){
$sortie[]=$data;
}
print(json_encode($sortie));
$rep->closeCursor();

これは Java コードの一部であり、結果パラメーターの jsonArray にはその値が含まれています (コンソールから):

 [{"id":"1","nom":"Fedson Dorvilme","email":"fedsondorvilme@gmail.com","phone":"34978238","img":"ic_launcher"},{"id":"2","nom":"Darlene Aurelien","email":"darleneaurelien@yahoo.fr","phone":"34171191","img":"ic_launcher"}]



        JSONArray array = new JSONArray(result);


        for (int i = 0; i < array.length(); i++) {
            JSONObject json_data = array.getJSONObject(i);

            Log.i("MyLogFlag", "Nom Contact: " + json_data.getString("nom"));
            returnString = "\n\t" + array.getJSONArray(i);
            System.out.println(" ********** RS [ "+returnString+" ]****************");

        }
    } catch (Exception e) {
        Log.e("log_Exception_tag", "Error parsing data " + e.toString());

    }

あなたの助けを前もって感謝します

4

1 に答える 1