2011-06-13 2 views
0

이것은 내 .java안드로이드는 MySQL 데이터베이스에서 테이블을 업데이트 할 수 없습니다

 
HttpClient httpclient = new DefaultHttpClient(); 
HttpPost httppost = new HttpPost(“http://*******.com/mobileproject/updateclass.php”); 
try { 
List nameValuePairsUpdate = new ArrayList(2); 
nameValuePairsUpdate.add(new BasicNameValuePair(“code”, aCode[i])); 
nameValuePairsUpdate.add(new BasicNameValuePair(“section”, aSection[i])); 
nameValuePairsUpdate.add(new BasicNameValuePair(“registered”, Integer.toString(registered))); 
nameValuePairsUpdate.add(new BasicNameValuePair(“empty”, Integer.toString(empty))); 
nameValuePairsUpdate.add(new BasicNameValuePair(“status”, status)); 
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 

HttpResponse response = httpclient.execute(httppost); 

} catch (ClientProtocolException e) { 
} catch (IOException e) { 
} 

이것은 내 .php

 
mysql_connect(“localhost”,”******”,”********”); 
mysql_select_db(“*******”); 
$registered = $_POST['registered']; 
$empty = $_POST['empty']; 
$status = $_POST['status']; 
$code = $_POST['code']; 
$section = $_POST['section']; 
mysql_query(“UPDATE Class SET registered = ‘$registered’ , empty = ‘$empty’ , status = ‘$status’ WHERE code = ‘$code’ AND section = ‘$section’”); 
내 문제는 단추 (.java의 코드), 등록 된 빈 및 상태 열 (초기 그들은 값을 포함하고) 비어있게됩니다.

+0

mysql_query가 반환하는 것은 무엇입니까? false를 리턴하면, mysql_error가 당신에게 무엇을 말합니까? (btw, 귀하의 게시물에 따옴표가 조금 이상합니다 - 아마도 잘라 내기/붙여 넣기 문제). – Mat

+0

HTTP 클라이언트의 "wire"출력을 확인하십시오. 값이 제출되면 적어도 보여줄 것입니다. 그렇지 않으면 SQL에서 바인드가 부족한 것을 제외하고는 모두 표면적으로 좋아 보인다. –

+0

나는 php에서 많은 경험이 없지만 나는 그 질문에 인용문이 있다고 생각하지 않는다. 아마 두 번 확인해 봐. 그것은 적절한 문자열 연결이 아닙니다. – DArkO

답변

0

시도는 상 mysql_query 같은에 넣어 문자열을 기록/에코합니다 :

$sql = “UPDATE Class SET registered = ‘$registered’ , empty = ‘$empty’ , status = ‘$status’ WHERE code = ‘$code’ AND section = ‘$section’”; 
echo $sql; // or yourowndebuglogfunction($sql); 
mysql_query($sql); 

을 그리고 MySQL의에서 직접 실행 해보십시오.

관련 문제