2011-04-04 44 views
0

我想要使用与PHP的MySQL Objective C的连接......NSURL和PHP连接

NSString *urlstr = [[NSString alloc] initWithFormat:@"http://61.17.213.62/r_o_t/hemen/contactFile/chkbook.php?fname=%@&lname=%@&num=%@&eml=%@",firstname.text,lastname.text,mobile.text,email.text]; 
    NSLog(@"urlstr :%@",urlstr); 

    NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:urlstr] ]; 
    NSLog(@"the request :%@",theRequest); 

    NSData *returnData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil]; 
    NSLog(@"returndata :%@",returnData); 

    NSString *listData = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding]; 
    NSLog(@"listData :%@",listData); 

是有任何其他方式使用PHP连接mysql ....这个代码?

+1

所以...什么是你的问题?这不工作? (它应该工作得很好)你得到什么错误?你有什么调试和想法?在您提供更多信息之前,这不是一个真正的问题。 – 2011-04-04 06:01:16

回答

0

还有其他的方法,如使用ASIHTTPRequest(http://allseeing-i.com/ASIHTTPRequest/),但它将几乎相同。

  1. 创建URL
  2. 创建请求
  3. 将请求发送
  4. 获取数据