Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将json格式的数据从iPhone发布到MySQL/PHP时出现问题_Php_Iphone_Mysql_Objective C_Json - Fatal编程技术网

将json格式的数据从iPhone发布到MySQL/PHP时出现问题

将json格式的数据从iPhone发布到MySQL/PHP时出现问题,php,iphone,mysql,objective-c,json,Php,Iphone,Mysql,Objective C,Json,我是iPhone开发的新手。以下是将json格式的数据从iPhone发布到MySQL的步骤。数据似乎是从iPhone发布的,但发布时出现问题 **- (IBAction) btnPostDataPressed : (id) sender { NSURL *objUrl = [NSURL URLWithString : @"http://localhost/test_questionnaire/update.php"] ; NSMutableURLRequest *theRe

我是iPhone开发的新手。以下是将json格式的数据从iPhone发布到MySQL的步骤。数据似乎是从iPhone发布的,但发布时出现问题

**- (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!!!";
}**
此外,我也尝试了上面注释掉的行,但仍然存在问题

希望得到积极的回应。谢谢。

您不能针对本地主机发帖,因为在这种情况下,它是您的手机


使用运行PHP/MySQL脚本的服务器的IP,如果没有可用的本地名称解析

会出现什么问题?服务器上有什么显示吗?谢谢你的反馈。嗯,页面被调用,但数据未发布。请你进一步指导好吗?