2009-11-04 5 views
0

저는 iphone.i의 초보자입니다. 내 application.i에 대한 로그인 페이지를 만들고 싶습니다. PHP 페이지에 연결하고 mysql 데이터베이스에서 해당 데이터를 검색하는 방법을 알아낼 수 없습니다. 어느 누구도 저에게 어떻게 가는지 안내해 줄 수는 없습니다.iphone에서 mysql에 액세스하는 방법

답변

0

아이폰은 php와 mysql 사이의 연결과 어떤 관계가 있습니까?

PHP는 웹 서버에서 실행될 것입니다. 일부 컴퓨터에 아파치가 설치되어 MySQL DB에 연결됩니다. 그러면 브라우저에서 아이폰의 php 페이지에 액세스하게됩니다. 브라우저를 제공하는 것 이외에 iPhone이 어떤 부분을 가지고 있는지 확실하지 않습니다.

0

예를 들어 NSURLConnection과 함께 사용할 수있는 NSURLRequest를보고 싶을 수 있습니다. URL에 대한 GET 매개 변수.

1) 설치 연결 자체에

receivedData =[NSMutableData data]; 
NSURLRequest *theRequest=[NSURLRequest requestWithURL:[NSURL URLWithString:url] 
              cachePolicy:NSURLRequestUseProtocolCachePolicy 
             timeoutInterval:20.0]; 
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 

2) 설정 위임 방법 :

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse*)response { 
    NSHTTPURLResponse * httpResponse = (NSHTTPURLResponse *) response; 

    if([httpResponse statusCode]==200) 
     [receivedData setLength:0]; 
    else 
     NSLog(@"Http-Reponse %u",[httpResponse statusCode]); 
     // HANDLE ERROR! 
} 

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 
    // append the new data to the receivedData 
    // receivedData is declared as a method instance elsewhere 
    [receivedData appendData:data]; 
} 



- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error { 
    // HANDLE THE CONNECTION ERROR 
    // release the connection, and the data object 
    [connection release]; 
    // receivedData is declared as a method instance elsewhere 
    [receivedData release]; 
} 

- (void)connectionDidFinishLoading:(NSURLConnection *)connection { 
    // receivedData contains the data 
    // convert to string: 
    NSLog(@"finished loading: %@",[[[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding] autorelease]); 
    [connection release]; 
    [receivedData release]; 
} 
0

당신은 인증을 노출 할 수 있습니다 당신은 들어오는 데이터에 응답 할 NSURLConnectionDelegate을 implment 수 있습니다 기능을 웹 서비스로 사용한 다음 Felix L.이 게시 한 URL로드 코드를 사용하여 웹 서비스에 대한 실제 연결을 시작하십시오.

서버에서 응답을 XML로 보내려는 경우 해당 응답을 NSXMLParser와 구문 분석합니다. 그렇지 않으면 원하는 형식으로 응답을 보내고 적절하게 구문 분석 할 수 있습니다 .

관련 문제