0
我试图插入到Web服务器上的数据库。即时通讯使用MYSQL,Appache和PHP通过webservice连接
的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;
}
谁能告诉我做什么我错在这里。我一直收到无效的代码,这是错误的请求400。帮帮我!这让我疯狂!
我把它拿出来,但它还没有经过。我无花果。这是给我一些问题,但我告诉了它,我从这个方法得到一个意想不到的错误 - (void)requestFinished:(ASIHTTPRequest *)请求。即时通讯使用IP地址在我的网址导致问题的事实? – user984373 2012-01-08 12:08:25
我怎样才能确保index.php接收一个值?我可以查询数据库以列出所有产品并将其显示在我的页面上。那工作找到。似乎index.php页面没有在我点击应用程序上的保存按钮时收到值。任何方式来检查这一点? – user984373 2012-01-08 12:14:59
不,使用数字IP地址不是问题。也许你需要从PHP端发回'200'响应,所以你的客户端的'requestFinished'方法会报告所有的都是成功的? – 2012-01-08 12:17:25