【发布时间】:2012-09-03 09:33:19
【问题描述】:
我想在我的数据库中存储 4 个值。 经度、纬度电话号码和时间戳。
我知道如何使用 NSLOG 将它们存储在本地,
但我想将它发送到我的 MySQL 数据库。
有人有一些教程或想在这里帮助我吗?
我非常需要这个,
您的帮助将不胜感激。
问候
更新
这是我需要存储在数据库中的一些代码
resultsLabel.text = [NSString stringWithFormat:@"(%@) %@ Location %.06f %.06f %@", ([UIApplication sharedApplication].applicationState == UIApplicationStateBackground) ? @"bg" : @"fg", resultsLabel.tag == 0 ? @"gps:" : @"sig" , newLocation.coordinate.latitude, newLocation.coordinate.longitude, [formatter stringFromDate:newLocation.timestamp]];
LocationTestAppDelegate * appDelegate = (LocationTestAppDelegate *)[UIApplication sharedApplication].delegate;
[appDelegate log:resultsLabel.text];
NSString* encodedValue = [newLocation.coordinate.latitude
stringByAddingPercentEscapesUsingEncoding:
NSASCIIStringEncoding];
//construct an URL for your script, containing the encoded text for parameter value
NSURL* url = [NSURL urlWithString:
[NSString stringWithFormat:
@"http://yourdomain.com/locatie.php?id=%@",
encodedValue]];
NSError* error = nil;
//send the request synchronously, store the response in result
NSString* result = [NSString stringWithContentsOfURL:url
encoding:NSUTF8StringEncoding
error:&error];
if (!error && ([result isEqualToString:@"OK"])) {
// everything went well
}
我需要存储文本字段中的电话号码、经度、纬度和时间戳。
问候(再次)
【问题讨论】:
-
我尝试过使用 SQLite,但直到现在这不起作用..
-
如果您发布代码,那么人们更有可能协助修复它并帮助您。 ;)
标签: php mysql ios http-post http-get