쿼리문을 안드로이드에서 php로 날린 후에 결과값을 리턴시켜서 처리하려고 하는데요.
여기저기 소스 참고해서
### 안드로이드
EditText txt = (EditText)findViewById(R.id.txt);
String value1 = "SELECT * FROM down_board WHERE latitude BETWEEN 37326001 AND 37354001 & longitude BETWEEN 127095799 AND 127123799;";
try {
// Construct data
String data = URLEncoder.encode("key1", "UTF-8") + "=" + URLEncoder.encode(value1, "UTF-8");
data += "&" + URLEncoder.encode("key2", "UTF-8") + "=" + URLEncoder.encode("홍길동", "UTF-8");
// Send data
URL url = new URL("http://badsector.mireene.com/sample.php");
URLConnection conn = url.openConnection();
// If you invoke the method setDoOutput(true) on the URLConnection, it will always use the POST method.
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write(data);
wr.flush();
// Get the response
BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
String line;
while ((line = rd.readLine()) != null) {
// System.out.println(line);
Log.i("line : ", line);
}
wr.close();
rd.close();
}
catch (Exception e) {
}
}
### php
<?
//request.setCharacterEncoding("UTF-8");
// 디비 연결문자열
include "dbconn.php";
// 쿼리문 생성
$sql = $key1;
// 쿼리문 실행
$result = mysql_query($sql, $connect);
// 레코드 총 갯수 반환
$total_record = mysql_num_rows($result);
echo "sum of records : ".$total_record;
echo "This is server response.";
echo "key1= ".$key1;
echo "key2= ".$key2;
mysql_close();
?>
이런 식으로 처리를 했거든요.
근데 쿼리문이 아니라 그냥 변수에 데이터만 넘길때는 잘 되는데...
쿼리문 자체를 넘기니깐 리턴값이 없어요. 왜이럴까요....




요 쿼리를 잘못썼었네요. ;;;; 중간의 &를 AND로 바꿔주니 되네요 ㅠㅠ 이거땜에 며칠을....