我從iphone應用發佈數據到服務器,但它在閱讀有關「多餘的錯誤訪問」的帖子行代碼時給出異常。我用於發送四個變量數據的同樣代碼,然後它工作正常我添加更多的變量後,它會給出錯誤。發佈數據到服務器從iphone應用
NSString*category=titleCategory;
NSString*sub_Category=titleSubCategory;
NSString*[email protected]"Audio";
content_Title=TitleTextField.text;
NSString*content_Title=content_Title;
NSString*[email protected]"Celeritas";
content_Description=descriptionTextField.text;
NSString*content_Description=content_Description;
NSString*[email protected]"10";
NSString*[email protected]"http://www.celeritas-solutions.com/pah_brd_v1/productivo/productivo/pro/ali.wav";
NSString *post =[[NSString alloc] initWithFormat:@"category=%@&sub_Category=%@&content_Type=%@&content_Title=%@&publisher=%@&content_Description=%@&content_ID=%@&content_Source=%@",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
NSURL *url=[NSURL URLWithString:@"http://www.celeritas-solutions.com/pah_brd_v1/productivo/addData.php"];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init] ;
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
NSLog(@"%@",data);
下面是它打破了代碼
NSString *post =[[NSString alloc] initWithFormat:@"category=%@&sub_Category=%@&content_Type=%@&content_Title=%@&publisher=%@&content_Description=%@&content_ID=%@&content_Source=%@",category,sub_Category,content_Type,content_Title,publisher,content_Description,content_ID,content_Source];
請在代碼中提及該行,您在哪裏得到錯誤。 – Bhavin 2013-03-20 07:41:02
...和錯誤的性質。 (例如錯誤日誌) – Groot 2013-03-20 07:41:28
@Vin我已經添加了錯誤行,請檢查 – 2013-03-20 07:47:11