Я тестировал свои навыки PHP, и, кажется, когда я пытаюсь отправить информацию из моего приложения Android в 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));
}