0
ウェブサーバー上のデータベースに挿入しようとしています。 MYSQL、AppacheとPHPウェブサービス経由で接続する
Xcodeの
*-(IBAction)saveRecord:(id)sender{
UITextField *description_txtfield = (UITextField*)[self.tableView viewWithTag:11];
description_string = description_txtfield.text;
NSLog(description_string);
NSURL *url = [NSURL URLWithString:@"http://192.168.1.140/~admin/qw/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:description_string forKey:@"product_name"];
[request setDelegate:self];
[request startAsynchronous];
[self.navigationController popToRootViewControllerAnimated:YES];
}
- (void)requestFinished:(ASIHTTPRequest *)request {
if (request.responseStatusCode == 400) {
NSLog(@"Invalid code");
} else if (request.responseStatusCode == 403) {
NSLog(@"Code already used");
} else if (request.responseStatusCode == 200) {
NSLog(@"OK");
} else {
NSLog(@"Unexpected error");
}
}*
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSError *error = [request error];
NSLog(error.localizedDescription);
}
index.php has the following code inside to handle insert.
Function redeem() {
// Check for required parameters
if (isset($_POST["product_name"])) {
// Put parameters into local variables
$rw_app_id = $_POST["product_name"];
// Add tracking of redemption
$stmt = $this->db->prepare("INSERT INTO inventory (product_name) VALUES (?)");
$stmt->bind_param($rw_app_id);
$stmt->execute();
$stmt->close();
}
return false;
}
誰かがここで間違って何イムを教えてもらえますを使用してイム。私は不正なRequest-400である無効なコードを取得し続けます。助けて!これは私をナッツを運転している!
私はそれを取り出しましたが、まだそれは通過しません。私はイチジク。それは私にいくつかの問題を与えていたが、私はそれを語って、このメソッドから予期しないエラーが出てきた。 - (void)requestFinished:(ASIHTTPRequest *)リクエスト。私のURLにIPアドレスを使用しているということが問題になるのでしょうか? – user984373
index.phpが値を受け取っていることを確認する方法はありますか?私はすべての製品をリストし、それを私のページに表示するためにデータベースに問い合わせることができます。それは働くことを見つける。 index.phpのページが私のアプリケーションの保存ボタンを押したときに値を受け取っていないようです。これをチェックする方法はありますか? – user984373
いいえ、数字のIPアドレスを使用しても問題はありません。おそらく、あなたのクライアントの 'requestFinished'メソッドがすべてが成功であったことを報告するように、PHP側から' 200'レスポンスを返す必要がありますか? –