【问题标题】:NSURL & PHP ConnectionNSURL 和 PHP 连接
【发布时间】:2011-07-28 22:27:06
【问题描述】:

我正在尝试将此代码用于目标 c 与 php mysql 的连接......

    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....?

【问题讨论】:

  • 那么...你的问题是什么?这不工作吗? (它应该可以正常工作)您遇到什么错误?您调试并发现了什么?在您提供更多信息之前,这不是一个真正的问题。

标签: php mysql objective-c nsurl


【解决方案1】:

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

  1. 创建网址
  2. 创建请求
  3. 发送请求
  4. 获取数据

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-12
    • 2011-01-27
    • 1970-01-01
    • 2012-10-07
    • 2011-12-18
    • 1970-01-01
    • 2023-04-01
    相关资源
    最近更新 更多