objective c - how insert data to remote database from ip+phone Application -


i accessing php website in iphone application.

i want user read blogs in iphone application , when comments on blog comment stored in website database.

any idea how this.

or need study talk remote database.....

thanks in advance.

when user read blogs , when give comment on blog u post comment php page save on 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);


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -