我有一个应用程序,我可以将数据发布到数据库并检索它,我发布了一个坐标数组,我从用户位置的移动中收集了这些坐标,例如
"37.351701,-122.105898",
"37.351945,-122.106109",
"37.352183,-122.106338",
"37.352409,-122.106568"
如果数组有大约180行,则不会将其发布到数据库,或者如果我跟踪从中收集坐标超过3分钟的用户也不会添加。我无法理解为什么会这样,我可以手动添加300行坐标,我可以从NSLog中取出数据库并检索它,但不是通过php从xcode发布它。
我如何创建坐标数组
if ((oldLocation.coordinate.latitude != newLocation.coordinate.latitude) &&
(oldLocation.coordinate.longitude != newLocation.coordinate.longitude))
self.trackCoord = [NSString stringWithFormat:@"%f,%f",newLocation.coordinate.latitude, newLocation.coordinate.longitude];
if (!self.trackArray) {
self.trackArray = [[NSMutableArray alloc] init];
}
[self.trackArray addObject:self.trackCoord];
我用它来发布数组
-(void) shareRoute:(NSString*) to withName:(NSString *) from withName:(NSString *) name withName:(NSString *) type withName:(NSString *) duration withName:(NSMutableArray *) trackArrayList{
if (from != nil && to != nil && name != nil){
NSMutableString *postString = [NSMutableString stringWithString:shareURL];
[postString appendString:[NSString stringWithFormat:@"?%@=%@", Sfrom, from]];
[postString appendString:[NSString stringWithFormat:@"&%@=%@", Sto, to]];
[postString appendString:[NSString stringWithFormat:@"&%@=%@", Sname, name]];
[postString appendString:[NSString stringWithFormat:@"&%@=%@", Stype, type]];
[postString appendString:[NSString stringWithFormat:@"&%@=%@", Sduration, duration]];
[postString appendString:[NSString stringWithFormat:@"&%@=%@", StrackArray, trackArrayList]];
[postString setString:[postString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:postString]];
[request setHTTPMethod:@"POST"];
postConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
}
}
和这个
- (IBAction)shareButton:(id)sender{
[self shareRoute:toLabel.text withName:fromLabel.text withName:routeNameTextField.text withName:typeLabel.text withName:durationLabel.text withName:trackArray];
[toLabel resignFirstResponder];
toLabel.text = nil;
fromLabel.text = nil;
routeNameTextField.text = nil;
typeLabel.text = nil;
durationLabel.text = nil;
trackArray = nil;
[[NSNotificationCenter defaultCenter] postNotificationName:@"Test1" object:self];
}
}
php code
$name = $_GET["name"];
$from = $_GET["from"];
$to = $_GET["to"];
$type = $_GET["type"];
$duration = $_GET["duration"];
$trackArray = $_GET["trackArray"];
$query = "INSERT INTO routes VALUES ('', '".mysql_real_escape_string($name)."', '".mysql_real_escape_string($from)."', '".mysql_real_escape_string($to)."', '$type', '$duration', '$trackArray')";
在数据库中,我尝试使用TEXT
的{{1}}和MEDIUMTEXT
值。
MySQL表。
trackArray
所有其他数据都已成功发布,我还发布了其他数组,其中包含多行和数据,但过多的数据显示使用以上作为示例。
为什么没有添加多行数组的任何想法?