Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-12-2011, 04:08 PM   #1 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Boston Ma. USA
Posts: 114
dickthedev is on a distinguished road
Default send gps data to mySql

Hi, I am trying to send the GPS Data to an existing php script to write to a MySQL database,

-(void) sendGPS {
NSLog(@"Sending URL");
NSURL *urlToSend = [[NSURL alloc] initWithString: @"http://www.myserver.com/phpscript.php?latitude=66.6666&longitude= 55.5555&altitude=44.4444"];

NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlToSend
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];
[urlToSend release];
[theConnection release];
}

What I did was using a NSTimer to call sendGPS every 10 minutes, What I can't figure out is why when the timer calls for the first time, the php script writes to the mySql database, but the subsequence calls, do not write any more, I am wondering if it's something wrong with this code, or the problem with th webserver configuration or something wrong with the php script?
dickthedev is offline   Reply With Quote
Old 09-12-2011, 04:16 PM   #2 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

For start, [code] tags please.

Second, this is very easy to pinpoint. Does your PHP script receive a message from your app on subsequent times, try logging this, if it does, then the problem is on the server side, if not, then it's in the app code.
baja_yu is offline   Reply With Quote
Old 09-12-2011, 04:44 PM   #3 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Boston Ma. USA
Posts: 114
dickthedev is on a distinguished road
Default

The problem seems to be timer related but I just don't know what it is, if I make a sequence of calls to the sendGPS a lot of [self sendGPS]s from ViewDidLoad, every single one is recorded in MySQL, once I put it in the timer
only the first time is recorded, I tried different time interval, from 1.0 to 10.0
the result is the same.
dickthedev is offline   Reply With Quote
Old 09-12-2011, 04:47 PM   #4 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by dickthedev View Post
The problem seems to be timer related but I just don't know what it is, if I make a sequence of calls to the sendGPS a lot of [self sendGPS]s from ViewDidLoad, every single one is recorded in MySQL, once I put it in the timer
only the first time is recorded, I tried different time interval, from 1.0 to 10.0
the result is the same.
Post your timer setup code....

Have you put an NSLog() or a breakpoint in your sendGPS() function to make sure it's actually getting called multiple times?
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 09-12-2011, 04:48 PM   #5 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

where do you set up the timer? Is it set to repeat=YES?
smithdale87 is offline   Reply With Quote
Old 09-12-2011, 05:00 PM   #6 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Boston Ma. USA
Posts: 114
dickthedev is on a distinguished road
Default

Thanks all for replying.

Quote:
Originally Posted by smithdale87 View Post
where do you set up the timer? Is it set to repeat=YES?
Yes and yes,

@MattW yes, at the beginning of the selector, I have a NSLog(@"Sending URL");
In the debug log, it shows the selector was called at the intended time interval.
dickthedev is offline   Reply With Quote
Old 09-12-2011, 07:39 PM   #7 (permalink)
Registered Member
 
Join Date: Oct 2009
Location: Boston Ma. USA
Posts: 114
dickthedev is on a distinguished road
Default

Quote:
Originally Posted by MattW View Post
Post your timer setup code....

Have you put an NSLog() or a breakpoint in your sendGPS() function to make sure it's actually getting called multiple times?
my timer code setup is just a generic code, nothing out of the ordinary, but I will let you be the judge of that, so here it is:
Code:
-(void) GPSTrackingTimer {
    trackingTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                     target:self 
                                   selector:@selector(sendURL) 
                                   userInfo:nil 
                                    repeats:YES];
    
}
and GPSTrackingTimer is called in viewDidLoad [self GPSTrackingTimer];
dickthedev is offline   Reply With Quote
Old 09-13-2011, 02:49 AM   #8 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 324
mariano_donati is on a distinguished road
Default

Quote:
Originally Posted by dickthedev View Post
my timer code setup is just a generic code, nothing out of the ordinary, but I will let you be the judge of that, so here it is:
Code:
-(void) GPSTrackingTimer {
    trackingTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
                                     target:self 
                                   selector:@selector(sendURL) 
                                   userInfo:nil 
                                    repeats:YES];
    
}
and GPSTrackingTimer is called in viewDidLoad [self GPSTrackingTimer];
Shouldn't it be sendGPS rather than sendURL on your timer's selector?
mariano_donati is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 401
9 members and 392 guests
7twenty7, Eclectic, eski, fiftysixty, JackReidy, teebee74, tim0504, UMAD, yuncarl28
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,672
Threads: 94,121
Posts: 402,904
Top Poster: BrianSlick (7,990)
Welcome to our newest member, yuncarl28
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:05 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0