LoginActivity.java
baseposte
は私のデータベースでUser
あり、含まれているテーブルでありNum_Compte
、Code_Compte
for (int i = 0; i < jArray.length(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
JSONObject e = jArray.getJSONObject(i);
String s = e.getString("post");
JSONObject jObject = new JSONObject(s);
map.put("num", jObject.getString("nomcompte"));
map.put("code", jObject.getString("codecompte"));
mylist.add(map);
}
connect.php
<?php
$json = file_get_contents('php://input');
$obj = json_decode($json);
$link = mysql_connect('localhost','root','') or die('Cannot connect to the DB');
mysql_select_db('baseposte',$link) or die('Cannot select the DB');
$query = "SELECT * FROM user where ".$obj->{'numcompte'}."=Num_Compte and ".$obj->{'codecompte'}."=Code_Compte";
$result = mysql_query($query) ;
/* create one master array of the records */
$posts = array();
if(mysql_num_rows($result)) {
while($post = mysql_fetch_assoc($result)) {
$posts[] = array('post'=>$post);
}
}
header('Content-type: application/json');
print(json_encode(array('posts'=>$posts)));
/* disconnect from the db */
@mysql_close($link);
?>
LogCat エラー
JSONException: Value <br of type java.lang.String cannot be converted to JSONObject
どこに問題があるのか わかりません。