필자는 PHP 기술을 시험해 보았습니다. 안드로이드 응용 프로그램에서 PHP로 정보를 보내려고 할 때 매개 변수 이름 만 보내는 것 같습니다 (데이터베이스에 Lname을 예를 들어.) 데이터베이스에. 우리는 PDO를 MySQL 데이터베이스와 통신하는 방법으로 사용하고 있습니다. 다음과 같이 여기 매개 변수와 관련된 문제
는 코딩입니다 : 당신은 당신의 쿼리 문자열에 리터럴 값을 포함했다$query = "INSERT INTO Customer (Lname, Fname, Address, City, State, ZIP, Phone, myusername, mypassword) VALUES (':Lname', ':Fname', ':Address', ':City', ':State', ':ZIP', ':Phone', ':myusername', ':mypassword')";
//Again, we need to update our tokens with the actual data:
$query_params = array(
':Lname' => $_POST['LName'],
':Fname' => $_POST['FName'],
':Address' => $_POST['Address'],
':City' => $_POST['City'],
':State' => $_POST['State'],
':ZIP' => $_POST['ZIP'],
':Phone' => $_POST['Phone'],
':myusername' => $_POST['username'],
':mypassword' => $_POST['password']
);
//time to run our query, and create the user
try {
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch (PDOException $ex) {
// For testing, you could use a die and message.
//die("Failed to run query: " . $ex->getMessage());
//or just use this use this one:
$response["success"] = 0;
$response["message"] = $ex->getMessage();
die(json_encode($response));
}