1
-(void) registerintoserverDB{
NSString *str_registerURL = @"reg_action.php";
NSString *str_completeURL = [NSString stringWithFormat:@"%@%@", str_global_domain, str_registerURL];
NSURL *url = [NSURL URLWithString:str_completeURL];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60];
[theRequest setHTTPMethod:@"POST"];
[theRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
NSString *str_address = [NSString stringWithFormat:@"%@%@", txt_address1.text, txt_address2.text];
NSString *postData = [NSString stringWithFormat:@"rest_name=%@&rest_telephone=%@&rest_email=%@&rest_password=%@&rest_country=%@&rest_city=%@&rest_postal=%@&rest_delivery=%@&rest_address=%@&rest_image=%@&rest_minimum_order=%@&isUser=%@&fb_name=%@fb_like", txt_restaurantname.text, txt_telephone.text, txt_email.text, txt_pass.text, txt_country.text, txt_city.text, txt_postal.text, txt_deliveryHours.text, str_address, @"imagepath", @"10 euro", @"Yes", str_global_user_fbUsername];
NSString *length = [NSString stringWithFormat:@"%d", [postData length]];
[theRequest setValue:length forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:[postData dataUsingEncoding:NSASCIIStringEncoding]];
NSURLConnection *sConnection = [NSURLConnection connectionWithRequest:theRequest delegate:self];
[sConnection start];
NSData *responseData = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:nil error:nil];
NSLog(@"response data is %@", responseData);
NSString *returnString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
NSLog(@"returnString....%@",returnString);
NSDictionary *response_dic = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:nil];
NSLog(@"msg is : %@ ",[response_dic objectForKey:@"msg"]);}
我想插入用户信息到服务器端的数据库,所以我用这一段代码,它工作正常,但问题是,在我的服务器数据库中的重复条目像2条记录一样插入相同的细节,我无法完全识别问题在我的代码端或服务器端。请尽快提出一些指导方针。提前致谢!重复插入记录在服务器数据库
嗨thanx alott !!!它的工作:) – Mak13 2013-02-16 13:45:15
你是伟大的迈克尔.. :)向你致敬.. – 2015-08-05 06:08:53
你是一个救命的人!您的建议帮助我解决了一个奇怪的问题,我试图通过几天来解决的通知。谢啦 !! – 2016-06-03 21:03:06