开发者

how insert data to remote database from ip+phone Application

I am accessing a php website in my iphone application.

i want that user read the blogs in their iphone application and when they comments on any blog the开发者_如何学Pythonir comment are stored in the website database.

any idea how to do this.

OR what i need to study to Talk with remote database.....

Thanks In advance.


When user read the blogs and when he give comment on that blog u simply post that comment to a php page which save it on the server.

NSString *post =[NSString stringWithFormat:@"comment=%@", myData];

NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];

] NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease]; [request setURL:[NSURL URLWithString:@"http://server.com/save-comment.php"]];

[request setHTTPMethod:@"POST"];

[request setValue:postLength forHTTPHeaderField:@"Content-Length"];

[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];

[request setHTTPBody:postData];

NSURLResponse *response; NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];

NSLog(@"Data: %@",data);

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜