iPhone 응용 프로그램에 문제가 있습니다. mysql 데이터베이스를 읽고 싶습니다. 한 가지 방법은 PHP를 통해 데이터를 제공하는 것입니다. ....iPhone SDK가 데이터를 PHP에서 가져 오는 중
이NSString *post = @"querystring=select productID, productName from products";
NSData *postData = [post dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:NO];
NSMutableURLRequest *urlRequest = [[[NSMutableURLRequest alloc] init] autorelease];
[urlRequest setURL:[NSURL URLWithString:@"http://localhost/versionsnews/test.php"]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setHTTPBody:postData];
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:&error];
if(!urlData) {
NSLog(@"Connection Failed!");
}
NSLog(@"Alles klar! empfangen:%d bytes",[urlData length]);
NSString *aStr = [[[NSString alloc] initWithData:urlData encoding:NSUTF8StringEncoding]autorelease];
NSLog(@"%@", aStr);
하지만 콘솔은 반환 중단 점에
http://img683.imageshack.us/img683/7868/screenmq.png
예! SQL 주입! –