학교 웹사이트를 학번과 비밀번호로 로그인 해서 정보를 받아오려고 가상으로 서버를 만들어서 테스트 중인데요
컴퓨터로 log_find.php로 연결 했을땐 1이 라는 값을 출력 합니다.
안드로이드로 했을땐 실행은 오류 없이 잘 되는데 이게 phpmyadmin 에서 로그를 보면
접속 한 흔적이 없습니다. 어디에 문제가 있나요?
아파치로 서버 돌리고 있습니다.
log_find.php
<?
include"./p_dbconn.php.inc";
$std_id = $_POST["id"];
$std_pw = $_POST["pw"];
$sql="select * from $tbl_name where std_id='$std_id' and std_pw='$std_pw'";
$result=mysql_query($sql,$connect);
$list=mysql_num_rows($result);
echo $list;
?>
안드로이드
package KST.Test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import android.app.Activity;
import android.os.Bundle;
public class Main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
InputStream is = null;
String totalMessage = "";
String url = "http://localhost:80/log_find.php";
HttpClient httpclient = new DefaultHttpClient();
try {
/** 연결 타입아웃내에 연결되는지 테스트, 5초 이내에 되지 않는다면 에러 */
String id = "0761001";
String pw = "55";
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("id", id));
nameValuePairs.add(new BasicNameValuePair("pw", pw));
/** 네트웍 연결해서 데이타 받아오기 */
String result = "";
HttpParams params = httpclient.getParams();
HttpConnectionParams.setConnectionTimeout(params, 5000);
HttpConnectionParams.setSoTimeout(params, 5000);
HttpPost httppost = new HttpPost(url);
UrlEncodedFormEntity entityRequest =
new UrlEncodedFormEntity(nameValuePairs, "UTF-8");
httppost.setEntity(entityRequest);
HttpResponse response = httpclient.execute(httppost);
HttpEntity entityResponse = response.getEntity();
is = entityResponse.getContent();
/** convert response to string */
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
is.close();
result = sb.toString();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
} finally {
httpclient.getConnectionManager().shutdown();
}
};
}




localhost는 동작하고 있는 기계의 루프백입니다.
서버상에서는 당연 localhost에 웹서버가 있으니 동작하겠지만 서버가 아닌 안드로이드 폰에서 localhost는 서버가 아니라 안드로이드 폰이라 접속이 되지 않겠네여.
localhost가 아닌 웹서버의 주소를 지정해서 다시 돌려 보세요.