저는 iPhone 개발의 초보자입니다. 다음은 iPhone에서 MySQL로 json의 데이터를 게시하는 방법입니다. 데이터는 iPhone에서 게시 된 것으로 보이지만 게시하는 동안 문제가 발생합니다.iPhone에서 MySQL/PHP로 json의 데이터를 게시 할 때 문제가 발생했습니다.
**- (IBAction) btnPostDataPressed : (id) sender {
NSURL *objUrl = [NSURL URLWithString : @"http://localhost/test_questionnaire/update.php"] ;
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL : objUrl] ;
[theRequest setHTTPMethod : @"POST"];
[theRequest setValue : @"application/json"
forHTTPHeaderField : @"Content-Type"];
[theRequest setTimeoutInterval:10];
//NSData *myData = [[NSString alloc] initWithString:@"nasir here"];
//[NSString alloc] initWithData:myData encoding:NSUTF8StringEncoding];
NSString *stringData = [[NSString alloc] initWithString:@"nasir here"];
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObject:stringData forKey:@"code"];
NSString *jsonString = [jsonDictionary JSONRepresentation];
NSString *strHttpBody = [NSString stringWithFormat:@"%@", jsonString];
[theRequest setHTTPBody:[strHttpBody dataUsingEncoding:NSUTF8StringEncoding]];
NSURLConnection *conn = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
textView.text = @"data successfully posted!!!";
}**
위의 주석 처리 된 줄로 시도했지만 여전히 문제가 남아 있습니다.
호핑을위한 호핑. 감사.
가능 지역 이름 확인이없는 경우/MySQL은 스크립트가 실행되고있는 서버 당신의 PHP의 IP? 서버에 아무것도 나타나지 않습니까? –